Documentation ¶
Overview ¶
Package rhp implements the Sia renter-host protocol, version 3.
Index ¶
- Constants
- Variables
- func CalculateHostPayouts(fc types.FileContract, minNewCollateral types.Currency, pt HostPriceTable, ...) (types.Currency, types.Currency, types.Currency, types.Currency, error)
- func CompareRegistryWork(r1, r2 RegistryEntry) int
- func ContractRenewalCost(cs consensus.State, pt HostPriceTable, fc types.FileContract, ...) types.Currency
- func PrepareContractRenewal(currentRevision types.FileContractRevision, ...) (types.FileContract, types.Currency, error)
- func RegistryHostID(pk types.PublicKey) types.Hash256
- func RenewalCosts(fc types.FileContract, pt HostPriceTable, expectedNewStorage, endHeight uint64) (_, _, _ types.Currency)
- func ValidateRegistryEntry(re RegistryEntry) (err error)
- func ValidateRegistryUpdate(old, update RegistryEntry, hostID types.Hash256) error
- type Account
- type FundAccountReceipt
- type HostPriceTable
- func (pt *HostPriceTable) AppendSectorCost(duration uint64) ResourceCost
- func (pt *HostPriceTable) AppendSectorRootCost(duration uint64) ResourceCost
- func (pt *HostPriceTable) BaseCost() ResourceCost
- func (pt *HostPriceTable) DropSectorsCost(n uint64) ResourceCost
- func (pt *HostPriceTable) HasSectorCost() ResourceCost
- func (pt *HostPriceTable) ReadOffsetCost(length uint64) ResourceCost
- func (pt *HostPriceTable) ReadRegistryCost() ResourceCost
- func (pt *HostPriceTable) ReadSectorCost(length uint64) ResourceCost
- func (pt *HostPriceTable) RevisionCost() ResourceCost
- func (pt *HostPriceTable) StoreSectorCost(duration uint64) ResourceCost
- func (pt *HostPriceTable) SwapSectorCost() ResourceCost
- func (pt *HostPriceTable) UpdateRegistryCost() ResourceCost
- func (pt *HostPriceTable) UpdateSectorCost(length uint64) ResourceCost
- type InstrAppendSector
- type InstrAppendSectorRoot
- type InstrDropSectors
- type InstrHasSector
- type InstrReadOffset
- type InstrReadRegistry
- type InstrReadRegistryNoVersion
- type InstrReadSector
- type InstrRevision
- type InstrStoreSector
- type InstrSwapSector
- type InstrUpdateRegistry
- type InstrUpdateRegistryNoType
- type InstrUpdateSector
- type Instruction
- type PayByContractRequest
- type PayByEphemeralAccountRequest
- type PaymentMethod
- type PaymentResponse
- type ProtocolObject
- type RPCAccountBalanceRequest
- type RPCAccountBalanceResponse
- type RPCError
- type RPCExecuteProgramRequest
- type RPCExecuteProgramResponse
- type RPCFinalizeProgramRequest
- type RPCFinalizeProgramResponse
- type RPCFundAccountRequest
- type RPCFundAccountResponse
- type RPCLatestRevisionRequest
- type RPCLatestRevisionResponse
- type RPCPriceTableResponse
- type RPCRenewContractHostAdditions
- type RPCRenewContractRequest
- type RPCRenewSignatures
- type RPCUpdatePriceTableResponse
- type RegistryEntry
- type RegistryKey
- type RegistryValue
- type ResourceCost
- type SettingsID
- type Stream
- func (s *Stream) Call(rpcID types.Specifier, req, resp ProtocolObject) error
- func (s *Stream) Close() error
- func (s *Stream) ReadID() (rpcID types.Specifier, err error)
- func (s *Stream) ReadRequest(req ProtocolObject, maxLen uint64) (err error)
- func (s *Stream) ReadResponse(resp ProtocolObject, maxLen uint64) (err error)
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) WriteRequest(rpcID types.Specifier, req ProtocolObject) error
- func (s *Stream) WriteResponse(resp ProtocolObject) (err error)
- func (s *Stream) WriteResponseErr(resp error) (err error)
- type Transport
Constants ¶
const ( // EntryTypeArbitrary is a registry value where all data is arbitrary. EntryTypeArbitrary = iota + 1 // EntryTypePubKey is a registry value where the first 20 bytes of data // corresponds to the hash of a host's public key. EntryTypePubKey )
const ( // MaxValueDataSize is the maximum size of a Value's Data // field. MaxValueDataSize = 113 )
Variables ¶
var ( RPCAccountBalanceID = types.NewSpecifier("AccountBalance") RPCExecuteProgramID = types.NewSpecifier("ExecuteProgram") RPCUpdatePriceTableID = types.NewSpecifier("UpdatePriceTable") RPCFundAccountID = types.NewSpecifier("FundAccount") RPCLatestRevisionID = types.NewSpecifier("LatestRevision") RPCRegistrySubscriptionID = types.NewSpecifier("Subscription") RPCFormContractID = types.NewSpecifier("FormContract") RPCRenewContractID = types.NewSpecifier("RenewContract") PaymentTypeContract = types.NewSpecifier("PayByContract") PaymentTypeEphemeralAccount = types.NewSpecifier("PayByEphemAcc") )
RPC IDs
Functions ¶
func CalculateHostPayouts ¶ added in v0.1.11
func CalculateHostPayouts(fc types.FileContract, minNewCollateral types.Currency, pt HostPriceTable, expectedNewStorage, endHeight uint64) (types.Currency, types.Currency, types.Currency, types.Currency, error)
CalculateHostPayouts calculates the contract payouts for the host.
func CompareRegistryWork ¶
func CompareRegistryWork(r1, r2 RegistryEntry) int
CompareRegistryWork compares the work of two registry entries.
func ContractRenewalCost ¶ added in v0.1.11
func ContractRenewalCost(cs consensus.State, pt HostPriceTable, fc types.FileContract, minerFee, basePrice types.Currency) types.Currency
ContractRenewalCost returns the cost of renewing a contract for the renter. In other words, this is the amount of money that the renter needs to fund the contract txn with.
func PrepareContractRenewal ¶ added in v0.1.11
func PrepareContractRenewal(currentRevision types.FileContractRevision, hostAddress, renterAddress types.Address, renterPayout, minNewCollateral types.Currency, pt HostPriceTable, expectedNewStorage, endHeight uint64) (types.FileContract, types.Currency, error)
PrepareContractRenewal constructs a contract renewal transaction.
func RegistryHostID ¶
RegistryHostID returns the ID hash of the host for primary registry entries.
func RenewalCosts ¶ added in v0.1.12
func RenewalCosts(fc types.FileContract, pt HostPriceTable, expectedNewStorage, endHeight uint64) (_, _, _ types.Currency)
RenewalCosts calculates the base price, base collateral and new collateral for a contract renewal taking into account the host's MaxCollateral setting and contract price.
func ValidateRegistryEntry ¶
func ValidateRegistryEntry(re RegistryEntry) (err error)
ValidateRegistryEntry validates the fields of a registry entry.
func ValidateRegistryUpdate ¶
func ValidateRegistryUpdate(old, update RegistryEntry, hostID types.Hash256) error
ValidateRegistryUpdate validates a registry update against the current entry. An updated registry entry must have a greater revision number, more work, or be replacing a non-primary registry entry.
Types ¶
type Account ¶
An Account is a public key used to identify an ephemeral account on a host.
var ZeroAccount Account
ZeroAccount is a sentinel value that indicates the lack of an account.
func (*Account) DecodeFrom ¶
DecodeFrom implements ProtocolObject.
func (Account) MarshalText ¶ added in v0.1.5
MarshalText implements encoding.TextUnmarshaler.
func (*Account) UnmarshalText ¶ added in v0.1.5
UnmarshalText implements encoding.TextUnmarshaler.
type FundAccountReceipt ¶
type FundAccountReceipt struct { Host types.UnlockKey Account Account Amount types.Currency Timestamp time.Time }
A FundAccountReceipt is a receipt for a payment made to an account.
func (*FundAccountReceipt) DecodeFrom ¶
func (r *FundAccountReceipt) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*FundAccountReceipt) EncodeTo ¶
func (r *FundAccountReceipt) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type HostPriceTable ¶
type HostPriceTable struct { // UID is a unique specifier that identifies this price table UID SettingsID `json:"uid"` // Validity is a duration that specifies how long the host guarantees these // prices for and are thus considered valid. Validity time.Duration `json:"validity"` // HostBlockHeight is the block height of the host. This allows the renter // to create valid withdrawal messages in case it is not synced yet. HostBlockHeight uint64 `json:"hostblockheight"` // UpdatePriceTableCost refers to the cost of fetching a new price table // from the host. UpdatePriceTableCost types.Currency `json:"updatepricetablecost"` // AccountBalanceCost refers to the cost of fetching the balance of an // ephemeral account. AccountBalanceCost types.Currency `json:"accountbalancecost"` // FundAccountCost refers to the cost of funding an ephemeral account on the // host. FundAccountCost types.Currency `json:"fundaccountcost"` // LatestRevisionCost refers to the cost of asking the host for the latest // revision of a contract. LatestRevisionCost types.Currency `json:"latestrevisioncost"` // SubscriptionMemoryCost is the cost of storing a byte of data for // SubscriptionPeriod time. SubscriptionMemoryCost types.Currency `json:"subscriptionmemorycost"` // SubscriptionNotificationCost is the cost of a single notification on top // of what is charged for bandwidth. SubscriptionNotificationCost types.Currency `json:"subscriptionnotificationcost"` // MDM related costs // // InitBaseCost is the amount of cost that is incurred when an MDM program // starts to run. This doesn't include the memory used by the program data. // The total cost to initialize a program is calculated as // InitCost = InitBaseCost + MemoryTimeCost * Time InitBaseCost types.Currency `json:"initbasecost"` // MemoryTimeCost is the amount of cost per byte per time that is incurred // by the memory consumption of the program. MemoryTimeCost types.Currency `json:"memorytimecost"` // Cost values specific to the bandwidth consumption. DownloadBandwidthCost types.Currency `json:"downloadbandwidthcost"` UploadBandwidthCost types.Currency `json:"uploadbandwidthcost"` // Cost values specific to the DropSectors instruction. DropSectorsBaseCost types.Currency `json:"dropsectorsbasecost"` DropSectorsUnitCost types.Currency `json:"dropsectorsunitcost"` // Cost values specific to the HasSector command. HasSectorBaseCost types.Currency `json:"hassectorbasecost"` // Cost values specific to the Read instruction. ReadBaseCost types.Currency `json:"readbasecost"` ReadLengthCost types.Currency `json:"readlengthcost"` // Cost values specific to the RenewContract instruction. RenewContractCost types.Currency `json:"renewcontractcost"` // Cost values specific to the Revision command. RevisionBaseCost types.Currency `json:"revisionbasecost"` // SwapSectorBaseCost is the cost of swapping 2 full sectors by root. SwapSectorBaseCost types.Currency `json:"swapsectorcost"` // Cost values specific to the Write instruction. WriteBaseCost types.Currency `json:"writebasecost"` // per write WriteLengthCost types.Currency `json:"writelengthcost"` // per byte written WriteStoreCost types.Currency `json:"writestorecost"` // per byte / block of additional storage // TxnFee estimations. TxnFeeMinRecommended types.Currency `json:"txnfeeminrecommended"` TxnFeeMaxRecommended types.Currency `json:"txnfeemaxrecommended"` // ContractPrice is the additional fee a host charges when forming/renewing // a contract to cover the miner fees when submitting the contract and // revision to the blockchain. ContractPrice types.Currency `json:"contractprice"` // CollateralCost is the amount of money per byte the host is promising to // lock away as collateral when adding new data to a contract. It's paid out // to the host regardless of the outcome of the storage proof. CollateralCost types.Currency `json:"collateralcost"` // MaxCollateral is the maximum amount of collateral the host is willing to // put into a single file contract. MaxCollateral types.Currency `json:"maxcollateral"` // MaxDuration is the max duration for which the host is willing to form a // contract. MaxDuration uint64 `json:"maxduration"` // WindowSize is the minimum time in blocks the host requests the // renewWindow of a new contract to be. WindowSize uint64 `json:"windowsize"` // Registry related fields. RegistryEntriesLeft uint64 `json:"registryentriesleft"` RegistryEntriesTotal uint64 `json:"registryentriestotal"` }
An HostPriceTable contains the host's current prices for each RPC.
func (*HostPriceTable) AppendSectorCost ¶ added in v0.1.6
func (pt *HostPriceTable) AppendSectorCost(duration uint64) ResourceCost
AppendSectorCost returns the cost of executing the AppendSector instruction.
func (*HostPriceTable) AppendSectorRootCost ¶ added in v0.1.6
func (pt *HostPriceTable) AppendSectorRootCost(duration uint64) ResourceCost
AppendSectorRootCost returns the cost of executing the AppendSectorRoot instruction.
func (*HostPriceTable) BaseCost ¶ added in v0.1.12
func (pt *HostPriceTable) BaseCost() ResourceCost
BaseCost is the cost of initialising an mdm program.
func (*HostPriceTable) DropSectorsCost ¶ added in v0.1.6
func (pt *HostPriceTable) DropSectorsCost(n uint64) ResourceCost
DropSectorsCost returns the cost of executing the DropSector instruction.
func (*HostPriceTable) HasSectorCost ¶ added in v0.1.6
func (pt *HostPriceTable) HasSectorCost() ResourceCost
HasSectorCost returns the cost of executing the HasSector instruction.
func (*HostPriceTable) ReadOffsetCost ¶ added in v0.1.6
func (pt *HostPriceTable) ReadOffsetCost(length uint64) ResourceCost
ReadOffsetCost returns the cost of executing the ReadOffset instruction.
func (*HostPriceTable) ReadRegistryCost ¶ added in v0.1.6
func (pt *HostPriceTable) ReadRegistryCost() ResourceCost
ReadRegistryCost returns the cost of executing the ReadRegistry instruction.
func (*HostPriceTable) ReadSectorCost ¶ added in v0.1.6
func (pt *HostPriceTable) ReadSectorCost(length uint64) ResourceCost
ReadSectorCost returns the cost of executing the ReadSector instruction.
func (*HostPriceTable) RevisionCost ¶ added in v0.1.6
func (pt *HostPriceTable) RevisionCost() ResourceCost
RevisionCost returns the cost of executing the Revision instruction.
func (*HostPriceTable) StoreSectorCost ¶ added in v0.1.6
func (pt *HostPriceTable) StoreSectorCost(duration uint64) ResourceCost
StoreSectorCost returns the cost of executing the StoreSector instruction.
func (*HostPriceTable) SwapSectorCost ¶
func (pt *HostPriceTable) SwapSectorCost() ResourceCost
SwapSectorCost returns the cost of executing the SwapSector instruction.
func (*HostPriceTable) UpdateRegistryCost ¶
func (pt *HostPriceTable) UpdateRegistryCost() ResourceCost
UpdateRegistryCost returns the cost of executing the UpdateRegistry instruction.
func (*HostPriceTable) UpdateSectorCost ¶ added in v0.1.6
func (pt *HostPriceTable) UpdateSectorCost(length uint64) ResourceCost
UpdateSectorCost returns the cost of executing the UpdateSector instruction.
type InstrAppendSector ¶
InstrAppendSector stores a sector on the host and appends its Merkle root to a contract.
func (*InstrAppendSector) DecodeFrom ¶
func (i *InstrAppendSector) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrAppendSector) EncodeTo ¶
func (i *InstrAppendSector) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrAppendSector) RequiresContract ¶
func (i *InstrAppendSector) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrAppendSector) RequiresFinalization ¶
func (i *InstrAppendSector) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrAppendSectorRoot ¶
InstrAppendSectorRoot appends a sector root to a contract
func (*InstrAppendSectorRoot) DecodeFrom ¶
func (i *InstrAppendSectorRoot) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrAppendSectorRoot) EncodeTo ¶
func (i *InstrAppendSectorRoot) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrAppendSectorRoot) RequiresContract ¶
func (i *InstrAppendSectorRoot) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrAppendSectorRoot) RequiresFinalization ¶
func (i *InstrAppendSectorRoot) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrDropSectors ¶
InstrDropSectors removes the last n sectors from a contract and deletes them from the host.
func (*InstrDropSectors) DecodeFrom ¶
func (i *InstrDropSectors) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrDropSectors) EncodeTo ¶
func (i *InstrDropSectors) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrDropSectors) RequiresContract ¶
func (i *InstrDropSectors) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrDropSectors) RequiresFinalization ¶
func (i *InstrDropSectors) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrHasSector ¶
type InstrHasSector struct {
MerkleRootOffset uint64
}
InstrHasSector checks if a sector is present on the host.
func (*InstrHasSector) DecodeFrom ¶
func (i *InstrHasSector) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrHasSector) EncodeTo ¶
func (i *InstrHasSector) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrHasSector) RequiresContract ¶
func (i *InstrHasSector) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrHasSector) RequiresFinalization ¶
func (i *InstrHasSector) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrReadOffset ¶
InstrReadOffset reads a range of bytes from an offset in the contract.
func (*InstrReadOffset) DecodeFrom ¶
func (i *InstrReadOffset) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrReadOffset) EncodeTo ¶
func (i *InstrReadOffset) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrReadOffset) RequiresContract ¶
func (i *InstrReadOffset) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrReadOffset) RequiresFinalization ¶
func (i *InstrReadOffset) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrReadRegistry ¶
type InstrReadRegistry struct { PublicKeyOffset uint64 PublicKeyLength uint64 TweakOffset uint64 Version uint8 }
InstrReadRegistry reads a value from the registry
func (*InstrReadRegistry) DecodeFrom ¶
func (i *InstrReadRegistry) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrReadRegistry) EncodeTo ¶
func (i *InstrReadRegistry) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrReadRegistry) RequiresContract ¶
func (i *InstrReadRegistry) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrReadRegistry) RequiresFinalization ¶
func (i *InstrReadRegistry) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrReadRegistryNoVersion ¶
type InstrReadRegistryNoVersion struct {
InstrReadRegistry
}
InstrReadRegistryNoVersion reads a pre-1.5.7 read registry Instruction without the version byte
func (*InstrReadRegistryNoVersion) DecodeFrom ¶
func (i *InstrReadRegistryNoVersion) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrReadRegistryNoVersion) EncodeTo ¶
func (i *InstrReadRegistryNoVersion) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
type InstrReadSector ¶
type InstrReadSector struct { LengthOffset uint64 OffsetOffset uint64 MerkleRootOffset uint64 ProofRequired bool }
InstrReadSector reads a range of bytes from a sector.
func (*InstrReadSector) DecodeFrom ¶
func (i *InstrReadSector) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrReadSector) EncodeTo ¶
func (i *InstrReadSector) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrReadSector) RequiresContract ¶
func (i *InstrReadSector) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrReadSector) RequiresFinalization ¶
func (i *InstrReadSector) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrRevision ¶
type InstrRevision struct{}
InstrRevision returns the latest revision of a contract
func (*InstrRevision) DecodeFrom ¶
func (i *InstrRevision) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrRevision) EncodeTo ¶
func (i *InstrRevision) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrRevision) RequiresContract ¶
func (i *InstrRevision) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrRevision) RequiresFinalization ¶
func (i *InstrRevision) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrStoreSector ¶
InstrStoreSector temporarily stores a sector on the host. The sector is not associated with any contract and collateral is not risked.
func (*InstrStoreSector) DecodeFrom ¶
func (i *InstrStoreSector) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrStoreSector) EncodeTo ¶
func (i *InstrStoreSector) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrStoreSector) RequiresContract ¶
func (i *InstrStoreSector) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrStoreSector) RequiresFinalization ¶
func (i *InstrStoreSector) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrSwapSector ¶
InstrSwapSector swaps two sectors in a contract
func (*InstrSwapSector) DecodeFrom ¶
func (i *InstrSwapSector) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrSwapSector) EncodeTo ¶
func (i *InstrSwapSector) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrSwapSector) RequiresContract ¶
func (i *InstrSwapSector) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrSwapSector) RequiresFinalization ¶
func (i *InstrSwapSector) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrUpdateRegistry ¶
type InstrUpdateRegistry struct { TweakOffset uint64 RevisionOffset uint64 SignatureOffset uint64 PublicKeyOffset uint64 PublicKeyLength uint64 DataOffset uint64 DataLength uint64 EntryType uint8 }
InstrUpdateRegistry updates a registry value.
func (*InstrUpdateRegistry) DecodeFrom ¶
func (i *InstrUpdateRegistry) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrUpdateRegistry) EncodeTo ¶
func (i *InstrUpdateRegistry) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrUpdateRegistry) RequiresContract ¶
func (i *InstrUpdateRegistry) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrUpdateRegistry) RequiresFinalization ¶
func (i *InstrUpdateRegistry) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type InstrUpdateRegistryNoType ¶
type InstrUpdateRegistryNoType struct {
InstrUpdateRegistry
}
InstrUpdateRegistryNoType reads a pre-1.5.7 update registry Instruction without the entry type byte
func (*InstrUpdateRegistryNoType) DecodeFrom ¶
func (i *InstrUpdateRegistryNoType) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrUpdateRegistryNoType) EncodeTo ¶
func (i *InstrUpdateRegistryNoType) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
type InstrUpdateSector ¶
InstrUpdateSector overwrites data in an existing sector.
func (*InstrUpdateSector) DecodeFrom ¶
func (i *InstrUpdateSector) DecodeFrom(d *types.Decoder)
DecodeFrom implements Instruction.
func (*InstrUpdateSector) EncodeTo ¶
func (i *InstrUpdateSector) EncodeTo(e *types.Encoder)
EncodeTo implements Instruction.
func (*InstrUpdateSector) RequiresContract ¶
func (i *InstrUpdateSector) RequiresContract() bool
RequiresContract implements Instruction.
func (*InstrUpdateSector) RequiresFinalization ¶
func (i *InstrUpdateSector) RequiresFinalization() bool
RequiresFinalization implements Instruction.
type Instruction ¶
type Instruction interface { ProtocolObject RequiresContract() bool RequiresFinalization() bool }
An Instruction is an MDM instruction.
type PayByContractRequest ¶
type PayByContractRequest struct { ContractID types.FileContractID RevisionNumber uint64 ValidProofValues []types.Currency MissedProofValues []types.Currency RefundAccount Account Signature types.Signature }
PayByContractRequest represents a payment made using a contract revision.
func PayByContract ¶
func PayByContract(rev *types.FileContractRevision, amount types.Currency, refundAcct Account, sk types.PrivateKey) (PayByContractRequest, bool)
PayByContract creates a PayByContractRequest by revising the supplied contract.
func (*PayByContractRequest) DecodeFrom ¶
func (r *PayByContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*PayByContractRequest) EncodeTo ¶
func (r *PayByContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
func (PayByContractRequest) SigHash ¶
func (p PayByContractRequest) SigHash(rev types.FileContractRevision) types.Hash256
SigHash returns the hash that is signed to authorize the contract payment.
type PayByEphemeralAccountRequest ¶
type PayByEphemeralAccountRequest struct { Account Account Expiry uint64 Amount types.Currency Nonce [8]byte Signature types.Signature Priority int64 }
PayByEphemeralAccountRequest represents a payment made using an ephemeral account.
func PayByEphemeralAccount ¶
func PayByEphemeralAccount(account Account, amount types.Currency, expiry uint64, sk types.PrivateKey) PayByEphemeralAccountRequest
PayByEphemeralAccount creates a PayByEphemeralAccountRequest.
func (*PayByEphemeralAccountRequest) DecodeFrom ¶
func (r *PayByEphemeralAccountRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*PayByEphemeralAccountRequest) EncodeTo ¶
func (r *PayByEphemeralAccountRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
func (PayByEphemeralAccountRequest) SigHash ¶
func (p PayByEphemeralAccountRequest) SigHash() types.Hash256
SigHash returns the hash that is signed to authorize the account payment.
type PaymentMethod ¶
type PaymentMethod interface { ProtocolObject // contains filtered or unexported methods }
A PaymentMethod is a way of paying for an arbitrary host operation.
type PaymentResponse ¶
PaymentResponse is the response to a payment request.
func (*PaymentResponse) DecodeFrom ¶
func (r *PaymentResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*PaymentResponse) EncodeTo ¶
func (r *PaymentResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type ProtocolObject ¶
type ProtocolObject interface { types.EncoderTo types.DecoderFrom }
A ProtocolObject can be transferred using the RHPv3 protocol.
type RPCAccountBalanceRequest ¶
type RPCAccountBalanceRequest struct {
Account Account
}
RPCAccountBalanceRequest is the request object for the AccountBalanceRequest RPC.
func (*RPCAccountBalanceRequest) DecodeFrom ¶
func (r *RPCAccountBalanceRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCAccountBalanceRequest) EncodeTo ¶
func (r *RPCAccountBalanceRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCAccountBalanceResponse ¶
RPCAccountBalanceResponse is the response object for the AccountBalanceResponse RPC.
func (*RPCAccountBalanceResponse) DecodeFrom ¶
func (r *RPCAccountBalanceResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCAccountBalanceResponse) EncodeTo ¶
func (r *RPCAccountBalanceResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCError ¶
type RPCError struct { Type types.Specifier Data []byte // structure depends on Type Description string // human-readable error string }
An RPCError may be sent instead of a response object to any RPC.
func (*RPCError) DecodeFrom ¶
DecodeFrom implements ProtocolObject.
type RPCExecuteProgramRequest ¶
type RPCExecuteProgramRequest struct { FileContractID types.FileContractID Program []Instruction ProgramData []byte }
RPCExecuteProgramRequest is the request object for the ExecuteProgramRequest RPC.
func (*RPCExecuteProgramRequest) DecodeFrom ¶
func (r *RPCExecuteProgramRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCExecuteProgramRequest) EncodeTo ¶
func (r *RPCExecuteProgramRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCExecuteProgramResponse ¶
type RPCExecuteProgramResponse struct { AdditionalCollateral types.Currency OutputLength uint64 NewMerkleRoot types.Hash256 NewSize uint64 Proof []types.Hash256 Error error TotalCost types.Currency FailureRefund types.Currency Output []byte }
RPCExecuteProgramResponse is the response object for the ExecuteProgramResponse RPC.
func (*RPCExecuteProgramResponse) DecodeFrom ¶
func (r *RPCExecuteProgramResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCExecuteProgramResponse) EncodeTo ¶
func (r *RPCExecuteProgramResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCFinalizeProgramRequest ¶ added in v0.1.6
type RPCFinalizeProgramRequest struct { Signature types.Signature RevisionNumber uint64 ValidProofValues []types.Currency MissedProofValues []types.Currency }
RPCFinalizeProgramRequest is the finalization request object for the ExecuteProgram RPC.
func (*RPCFinalizeProgramRequest) DecodeFrom ¶ added in v0.1.6
func (r *RPCFinalizeProgramRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFinalizeProgramRequest) EncodeTo ¶ added in v0.1.6
func (r *RPCFinalizeProgramRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCFinalizeProgramResponse ¶ added in v0.1.6
RPCFinalizeProgramResponse is the response object for finalizing the ExecuteProgram RPC
func (*RPCFinalizeProgramResponse) DecodeFrom ¶ added in v0.1.6
func (r *RPCFinalizeProgramResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFinalizeProgramResponse) EncodeTo ¶ added in v0.1.6
func (r *RPCFinalizeProgramResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCFundAccountRequest ¶
type RPCFundAccountRequest struct {
Account Account
}
RPCFundAccountRequest is the request object for the FundAccountRequest RPC.
func (*RPCFundAccountRequest) DecodeFrom ¶
func (r *RPCFundAccountRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFundAccountRequest) EncodeTo ¶
func (r *RPCFundAccountRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCFundAccountResponse ¶
type RPCFundAccountResponse struct { Balance types.Currency Receipt FundAccountReceipt Signature types.Signature }
RPCFundAccountResponse is the response object for the FundAccountResponse RPC.
func (*RPCFundAccountResponse) DecodeFrom ¶
func (r *RPCFundAccountResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFundAccountResponse) EncodeTo ¶
func (r *RPCFundAccountResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCLatestRevisionRequest ¶ added in v0.1.11
type RPCLatestRevisionRequest struct {
ContractID types.FileContractID
}
RPCLatestRevisionRequest is the request object for the latest revision RPC.
func (*RPCLatestRevisionRequest) DecodeFrom ¶ added in v0.1.11
func (r *RPCLatestRevisionRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCLatestRevisionRequest) EncodeTo ¶ added in v0.1.11
func (r *RPCLatestRevisionRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCLatestRevisionResponse ¶ added in v0.1.11
type RPCLatestRevisionResponse struct {
Revision types.FileContractRevision
}
RPCLatestRevisionResponse is the response object for the latest revision RPC.
func (*RPCLatestRevisionResponse) DecodeFrom ¶ added in v0.1.11
func (r *RPCLatestRevisionResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCLatestRevisionResponse) EncodeTo ¶ added in v0.1.11
func (r *RPCLatestRevisionResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCPriceTableResponse ¶
type RPCPriceTableResponse struct{}
RPCPriceTableResponse is the response object for the PriceTableResponse RPC.
func (RPCPriceTableResponse) DecodeFrom ¶
func (RPCPriceTableResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (RPCPriceTableResponse) EncodeTo ¶
func (RPCPriceTableResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCRenewContractHostAdditions ¶ added in v0.1.11
type RPCRenewContractHostAdditions struct { Parents []types.Transaction SiacoinInputs []types.SiacoinInput SiacoinOutputs []types.SiacoinOutput FinalRevisionSignature types.Signature }
RPCRenewContractHostAdditions is a response object containing the host's additions for the renew contract RPC.
func (*RPCRenewContractHostAdditions) DecodeFrom ¶ added in v0.1.11
func (r *RPCRenewContractHostAdditions) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject
func (*RPCRenewContractHostAdditions) EncodeTo ¶ added in v0.1.11
func (r *RPCRenewContractHostAdditions) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject
type RPCRenewContractRequest ¶ added in v0.1.11
type RPCRenewContractRequest struct { TransactionSet []types.Transaction RenterKey types.UnlockKey FinalRevisionSignature types.Signature }
RPCRenewContractRequest is the request object for the renew contract RPC.
func (*RPCRenewContractRequest) DecodeFrom ¶ added in v0.1.11
func (r *RPCRenewContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject
func (*RPCRenewContractRequest) EncodeTo ¶ added in v0.1.11
func (r *RPCRenewContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCRenewSignatures ¶ added in v0.1.11
type RPCRenewSignatures struct { TransactionSignatures []types.TransactionSignature RevisionSignature types.TransactionSignature }
RPCRenewSignatures is a response object for transferring signatures in the renew contract RPC.
func (*RPCRenewSignatures) DecodeFrom ¶ added in v0.1.11
func (r *RPCRenewSignatures) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject
func (*RPCRenewSignatures) EncodeTo ¶ added in v0.1.11
func (r *RPCRenewSignatures) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject
type RPCUpdatePriceTableResponse ¶
type RPCUpdatePriceTableResponse struct {
PriceTableJSON []byte
}
RPCUpdatePriceTableResponse is the response object for the UpdatePriceTableResponse RPC.
func (*RPCUpdatePriceTableResponse) DecodeFrom ¶
func (r *RPCUpdatePriceTableResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCUpdatePriceTableResponse) EncodeTo ¶
func (r *RPCUpdatePriceTableResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RegistryEntry ¶
type RegistryEntry struct { RegistryKey RegistryValue }
A RegistryEntry contains the data stored by a host for each registry value.
func (*RegistryEntry) Hash ¶
func (re *RegistryEntry) Hash() types.Hash256
Hash returns the hash used for signing the entry.
func (*RegistryEntry) Work ¶
func (re *RegistryEntry) Work() types.Hash256
Work returns the work of an entry.
type RegistryKey ¶
A RegistryKey uniquely identifies a value in the host's registry.
func (*RegistryKey) Hash ¶
func (rk *RegistryKey) Hash() types.Hash256
Hash returns the hash of the key.
type RegistryValue ¶
A RegistryValue is a value associated with a key and a tweak in a host's registry.
type ResourceCost ¶ added in v0.1.6
type ResourceCost struct { // Base is the cost to execute the instruction. It is not refunded if // the instruction fails. Base types.Currency // Storage is the cost to store the instruction's data. Storage is the // additional storage usage in bytes used. It is refunded if the // program fails. Storage types.Currency // Collateral is the amount of collateral that must be risked by the // host to execute the instruction. It is freed if the instruction // fails. Collateral types.Currency // Egress is the cost to send the instruction's output to the renter. It // is not refunded if the program fails. Egress types.Currency // Ingress is the cost to receive the instruction's input from the // renter. It is not refunded if the program fails. Ingress types.Currency }
ResourceCost is the cost of executing an instruction.
func (ResourceCost) Add ¶ added in v0.1.6
func (a ResourceCost) Add(b ResourceCost) ResourceCost
Add adds two ResourceCosts together.
func (ResourceCost) Total ¶ added in v0.1.6
func (a ResourceCost) Total() (cost, collateral types.Currency)
Total returns the total cost and collateral of a ResourceCost.
type SettingsID ¶
type SettingsID [16]byte
A SettingsID is a unique identifier for registered host settings used by renters when interacting with the host.
func (*SettingsID) DecodeFrom ¶
func (s *SettingsID) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*SettingsID) EncodeTo ¶
func (s *SettingsID) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
func (*SettingsID) LoadString ¶
func (s *SettingsID) LoadString(input string) error
LoadString loads the unique id from the given string.
func (SettingsID) MarshalJSON ¶
func (s SettingsID) MarshalJSON() ([]byte, error)
MarshalJSON marshals an id as a hex string.
func (*SettingsID) UnmarshalJSON ¶
func (s *SettingsID) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the json hex string of the id.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
A Stream is a duplex connection over which RPCs can be sent and received.
func (*Stream) Call ¶
func (s *Stream) Call(rpcID types.Specifier, req, resp ProtocolObject) error
Call is a helper method that writes a request and then reads a response.
func (*Stream) ReadRequest ¶
func (s *Stream) ReadRequest(req ProtocolObject, maxLen uint64) (err error)
ReadRequest reads an RPC request using the new loop protocol.
func (*Stream) ReadResponse ¶
func (s *Stream) ReadResponse(resp ProtocolObject, maxLen uint64) (err error)
ReadResponse reads an RPC response. If the response is an error, it is returned directly.
func (*Stream) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the Stream.
func (*Stream) WriteRequest ¶
func (s *Stream) WriteRequest(rpcID types.Specifier, req ProtocolObject) error
WriteRequest sends an encrypted RPC request, comprising an RPC ID and a request object.
func (*Stream) WriteResponse ¶
func (s *Stream) WriteResponse(resp ProtocolObject) (err error)
WriteResponse writes an RPC response object.
func (*Stream) WriteResponseErr ¶
WriteResponseErr writes an error. If err is an *RPCError, it is sent directly; otherwise, a generic RPCError is created from err's Error string.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
A Transport facilitates the exchange of RPCs via the renter-host protocol, version 3.
func NewHostTransport ¶
NewHostTransport establishes a new RHPv3 session over the supplied connection.
func NewRenterTransport ¶
NewRenterTransport establishes a new RHPv3 session over the supplied connection.
func (*Transport) AcceptStream ¶
AcceptStream accepts a new stream from the renter.
func (*Transport) DialStream ¶
DialStream opens a new stream with the host.