gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/renter/proto/proto.go (about)

     1  package proto
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"gitlab.com/SiaPrime/SiaPrime/modules"
     7  	"gitlab.com/SiaPrime/SiaPrime/types"
     8  )
     9  
    10  // Dependencies.
    11  type (
    12  	transactionBuilder interface {
    13  		AddArbitraryData(arb []byte) uint64
    14  		AddFileContract(types.FileContract) uint64
    15  		AddMinerFee(types.Currency) uint64
    16  		AddParents([]types.Transaction)
    17  		AddSiacoinInput(types.SiacoinInput) uint64
    18  		AddSiacoinOutput(types.SiacoinOutput) uint64
    19  		AddTransactionSignature(types.TransactionSignature) uint64
    20  		FundSiacoins(types.Currency) error
    21  		Sign(bool) ([]types.Transaction, error)
    22  		UnconfirmedParents() ([]types.Transaction, error)
    23  		View() (types.Transaction, []types.Transaction)
    24  		ViewAdded() (parents, coins, funds, signatures []int)
    25  	}
    26  
    27  	transactionPool interface {
    28  		AcceptTransactionSet([]types.Transaction) error
    29  		FeeEstimation() (min types.Currency, max types.Currency)
    30  	}
    31  
    32  	hostDB interface {
    33  		IncrementSuccessfulInteractions(key types.SiaPublicKey)
    34  		IncrementFailedInteractions(key types.SiaPublicKey)
    35  	}
    36  )
    37  
    38  // ContractParams are supplied as an argument to FormContract.
    39  type ContractParams struct {
    40  	Allowance     modules.Allowance
    41  	Host          modules.HostDBEntry
    42  	Funding       types.Currency
    43  	StartHeight   types.BlockHeight
    44  	EndHeight     types.BlockHeight
    45  	RefundAddress types.UnlockHash
    46  	RenterSeed    EphemeralRenterSeed
    47  	// TODO: add optional keypair
    48  }
    49  
    50  // A revisionNumberMismatchError occurs if the host reports a different revision
    51  // number than expected.
    52  type revisionNumberMismatchError struct {
    53  	ours, theirs uint64
    54  }
    55  
    56  func (e *revisionNumberMismatchError) Error() string {
    57  	return fmt.Sprintf("our revision number (%v) does not match the host's (%v); the host may be acting maliciously", e.ours, e.theirs)
    58  }
    59  
    60  // IsRevisionMismatch returns true if err was caused by the host reporting a
    61  // different revision number than expected.
    62  func IsRevisionMismatch(err error) bool {
    63  	_, ok := err.(*revisionNumberMismatchError)
    64  	return ok
    65  }