gitlab.com/SkynetLabs/skyd@v1.6.9/skymodules/renter/proto/proto.go (about)

     1  package proto
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"go.sia.tech/siad/modules"
     7  	"go.sia.tech/siad/types"
     8  )
     9  
    10  // Dependencies.
    11  type (
    12  	transactionBuilder interface {
    13  		AddArbitraryData(arb []byte) uint64
    14  		AddFileContract(types.FileContract) uint64
    15  		AddFileContractRevision(types.FileContractRevision) uint64
    16  		AddMinerFee(types.Currency) uint64
    17  		AddParents([]types.Transaction)
    18  		AddSiacoinInput(types.SiacoinInput) uint64
    19  		AddSiacoinOutput(types.SiacoinOutput) uint64
    20  		AddTransactionSignature(types.TransactionSignature) uint64
    21  		Copy() modules.TransactionBuilder
    22  		FundSiacoins(types.Currency) error
    23  		Sign(bool) ([]types.Transaction, error)
    24  		UnconfirmedParents() ([]types.Transaction, error)
    25  		View() (types.Transaction, []types.Transaction)
    26  		ViewAdded() (parents, coins, funds, signatures []int)
    27  	}
    28  
    29  	transactionPool interface {
    30  		AcceptTransactionSet([]types.Transaction) error
    31  		FeeEstimation() (min types.Currency, max types.Currency)
    32  	}
    33  
    34  	hostDB interface {
    35  		IncrementSuccessfulInteractions(key types.SiaPublicKey) error
    36  		IncrementFailedInteractions(key types.SiaPublicKey) error
    37  	}
    38  )
    39  
    40  // A revisionNumberMismatchError occurs if the host reports a different revision
    41  // number than expected.
    42  type revisionNumberMismatchError struct {
    43  	ours, theirs uint64
    44  }
    45  
    46  func (e *revisionNumberMismatchError) Error() string {
    47  	return fmt.Sprintf("our revision number (%v) does not match the host's (%v); the host may be acting maliciously", e.ours, e.theirs)
    48  }
    49  
    50  // IsRevisionMismatch returns true if err was caused by the host reporting a
    51  // different revision number than expected.
    52  func IsRevisionMismatch(err error) bool {
    53  	_, ok := err.(*revisionNumberMismatchError)
    54  	return ok
    55  }