Documentation ¶
Overview ¶
Package rhp implements the Sia renter-host protocol.
Index ¶
- Constants
- Variables
- func BuildProof(sector *[SectorSize]byte, start, end uint64, ...) []types.Hash256
- func BuildSectorRangeProof(sectorRoots []types.Hash256, start, end uint64) []types.Hash256
- func DiffProofSize(n int, actions []RPCWriteAction) int
- func FinalizeProgramRevision(fc types.FileContract, burn types.Currency) (types.FileContract, error)
- func InstructionRequiresContract(i Instruction) bool
- func InstructionRequiresFinalization(i Instruction) bool
- func MetaRoot(roots []types.Hash256) types.Hash256
- func PaymentRevision(fc types.FileContract, amount types.Currency) (types.FileContract, error)
- func ProofSize(n, i uint64) uint64
- func RPCReadRenterCost(settings HostSettings, sections []RPCReadRequestSection) types.Currency
- func RPCWriteHostCollateral(settings HostSettings, fc types.FileContract, actions []RPCWriteAction) types.Currency
- func RPCWriteRenterCost(settings HostSettings, fc types.FileContract, actions []RPCWriteAction) types.Currency
- func RangeProofSize(n, start, end uint64) uint64
- func ReadSector(r io.Reader) (types.Hash256, *[SectorSize]byte, error)
- func ReaderRoot(r io.Reader) (types.Hash256, error)
- func RegistryHostID(pub types.PublicKey) types.Hash256
- func RegistryKey(pub types.PublicKey, tweak types.Hash256) types.Hash256
- func SectorRoot(sector *[SectorSize]byte) types.Hash256
- func ValidateContractFinalization(current, final types.FileContract) error
- func ValidateContractFormation(fc types.FileContract, currentHeight uint64, settings HostSettings) error
- func ValidateContractRenewal(existing, renewal types.FileContract, currentHeight uint64, ...) error
- func ValidateContractSignatures(cs consensus.State, fc types.FileContract) (err error)
- func ValidatePaymentRevision(current, revision types.FileContract, amount types.Currency) error
- func ValidateProgramRevision(current, revision types.FileContract, ...) error
- func ValidateRegistryEntry(value RegistryValue) (err error)
- func ValidateRegistryUpdate(old, update RegistryValue, hostID types.Hash256) error
- func VerifyAppendProof(numLeaves uint64, treeHashes []types.Hash256, ...) bool
- type Contract
- type ContractOutputs
- type HostSettings
- type InstrAppendSector
- type InstrContractRevision
- type InstrDropSectors
- type InstrHasSector
- type InstrReadOffset
- type InstrReadRegistry
- type InstrReadSector
- type InstrSectorRoots
- type InstrSwapSector
- type InstrUpdateRegistry
- type InstrUpdateSector
- type Instruction
- type PayByContractRequest
- type PayByEphemeralAccountRequest
- type ProgramBuilder
- func (pb *ProgramBuilder) AddAppendSectorInstruction(sector *[SectorSize]byte, proof bool)
- func (pb *ProgramBuilder) AddDropSectorInstruction(sectors uint64, proof bool)
- func (pb *ProgramBuilder) AddDropSectorsInstruction(sectors uint64, proof bool)
- func (pb *ProgramBuilder) AddHasSectorInstruction(root types.Hash256)
- func (pb *ProgramBuilder) AddReadOffsetInstruction(offset, length uint64, proof bool)
- func (pb *ProgramBuilder) AddReadRegistryInstruction(pub types.PublicKey, tweak types.Hash256)
- func (pb *ProgramBuilder) AddReadSectorInstruction(root types.Hash256, offset uint64, length uint64, proof bool) error
- func (pb *ProgramBuilder) AddRevisionInstruction()
- func (pb *ProgramBuilder) AddSectorRootsInstruction(sectors uint64)
- func (pb *ProgramBuilder) AddSwapSectorInstruction(i, j uint64, proof bool)
- func (pb *ProgramBuilder) AddUpdateRegistryInstruction(value RegistryValue)
- func (pb *ProgramBuilder) AddUpdateSectorInstruction(offset uint64, data []byte, proof bool) error
- func (pb *ProgramBuilder) Cost() ResourceUsage
- func (pb *ProgramBuilder) Program() (instructions []Instruction, requiresContract, requiresFinalization bool, ...)
- type RPCAccountBalanceRequest
- type RPCAccountBalanceResponse
- type RPCContractSignatures
- type RPCExecuteInstrResponse
- type RPCExecuteProgramRequest
- type RPCFinalizeProgramRequest
- type RPCFormContractHostAdditions
- type RPCFormContractRequest
- type RPCFundAccountRequest
- type RPCFundAccountResponse
- type RPCLatestRevisionRequest
- type RPCLatestRevisionResponse
- type RPCLockRequest
- type RPCLockResponse
- type RPCReadRequest
- type RPCReadRequestSection
- type RPCReadResponse
- type RPCRenewContractHostAdditions
- type RPCRenewContractRenterSignatures
- type RPCRenewContractRequest
- type RPCRevisionSigningResponse
- type RPCSectorRootsRequest
- type RPCSectorRootsResponse
- type RPCSettingsRegisteredResponse
- type RPCSettingsResponse
- type RPCWriteAction
- type RPCWriteMerkleProof
- type RPCWriteRequest
- type RPCWriteResponse
- type RangeProofVerifier
- type Receipt
- type RegistryValue
- type ResourceUsage
- func AppendSectorCost(settings HostSettings, duration uint64) (costs ResourceUsage)
- func DropSectorsCost(settings HostSettings, n uint64) (costs ResourceUsage)
- func ExecutionCost(settings HostSettings, data, instructions uint64, requiresFinalization bool) (costs ResourceUsage)
- func HasSectorCost(settings HostSettings) (costs ResourceUsage)
- func ReadCost(settings HostSettings, l uint64) (costs ResourceUsage)
- func ReadRegistryCost(settings HostSettings) (costs ResourceUsage)
- func RevisionCost(settings HostSettings) (costs ResourceUsage)
- func SectorRootsCost(settings HostSettings, sectors uint64) (costs ResourceUsage)
- func SwapSectorCost(settings HostSettings) (costs ResourceUsage)
- func UpdateRegistryCost(settings HostSettings) (costs ResourceUsage)
- func UpdateSectorCost(settings HostSettings, l uint64) (costs ResourceUsage)
- type Session
- type SettingsID
- type WithdrawalMessage
Constants ¶
const ( // SectorSize is the size of one sector in bytes. SectorSize = 1 << 22 // 4 MiB // LeafSize is the size of one leaf in bytes. LeafSize = 64 // LeavesPerSector is the number of leaves in one sector. LeavesPerSector = SectorSize / LeafSize )
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 ( // ErrInvalidRenterSignature is returned when a contract's renter signature is invalid. ErrInvalidRenterSignature = errors.New("invalid renter signature") // ErrInvalidHostSignature is returned when a contract's host signature is invalid. ErrInvalidHostSignature = errors.New("invalid host signature") )
var ( SpecInstrAppendSector = rpc.NewSpecifier("AppendSector") SpecInstrUpdateSector = rpc.NewSpecifier("UpdateSector") SpecInstrDropSectors = rpc.NewSpecifier("DropSectors") SpecInstrHasSector = rpc.NewSpecifier("HasSector") SpecInstrReadOffset = rpc.NewSpecifier("ReadOffset") SpecInstrReadSector = rpc.NewSpecifier("ReadSector") SpecInstrContractRevision = rpc.NewSpecifier("Revision") SpecInstrSectorRoots = rpc.NewSpecifier("SectorRoots") SpecInstrSwapSector = rpc.NewSpecifier("SwapSector") SpecInstrUpdateRegistry = rpc.NewSpecifier("UpdateRegistry") SpecInstrReadRegistry = rpc.NewSpecifier("ReadRegistry") SpecInstrReadRegistrySID = rpc.NewSpecifier("ReadRegistrySID") )
Specifiers for MDM instructions
var ( RPCLockID = rpc.NewSpecifier("Lock") RPCReadID = rpc.NewSpecifier("Read") RPCSectorRootsID = rpc.NewSpecifier("SectorRoots") RPCUnlockID = rpc.NewSpecifier("Unlock") RPCWriteID = rpc.NewSpecifier("Write") RPCAccountBalanceID = rpc.NewSpecifier("AccountBalance") RPCExecuteProgramID = rpc.NewSpecifier("ExecuteProgram") RPCFundAccountID = rpc.NewSpecifier("FundAccount") RPCFormContractID = rpc.NewSpecifier("FormContract") RPCLatestRevisionID = rpc.NewSpecifier("LatestRevision") RPCRenewContractID = rpc.NewSpecifier("RenewContract") RPCSettingsID = rpc.NewSpecifier("Settings") )
RPC IDs
var ( RPCWriteActionAppend = rpc.NewSpecifier("Append") RPCWriteActionTrim = rpc.NewSpecifier("Trim") RPCWriteActionSwap = rpc.NewSpecifier("Swap") RPCWriteActionUpdate = rpc.NewSpecifier("Update") RPCReadStop = rpc.NewSpecifier("ReadStop") )
Read/Write actions
var ( PayByContract = rpc.NewSpecifier("PayByContract") PayByEphemeralAccount = rpc.NewSpecifier("PayByEphemAcc") )
Payment specifiers are used to specify the payment type
var ErrRenterClosed = errors.New("renter has terminated session")
ErrRenterClosed is returned by (*Session).ReadID when the renter sends the session termination signal.
Functions ¶
func BuildProof ¶
func BuildProof(sector *[SectorSize]byte, start, end uint64, precalc func(i, j uint64) types.Hash256) []types.Hash256
BuildProof constructs a proof for the segment range [start, end). If a non- nil precalc function is provided, it will be used to supply precalculated subtree Merkle roots. For example, if the root of the left half of the Merkle tree is precomputed, precalc should return it for i == 0 and j == SegmentsPerSector/2. If a precalculated root is not available, precalc should return the zero hash.
func BuildSectorRangeProof ¶
BuildSectorRangeProof constructs a proof for the sector range [start, end).
func DiffProofSize ¶
func DiffProofSize(n int, actions []RPCWriteAction) int
DiffProofSize returns the size of a Merkle diff proof for the specified actions within a tree containing n leaves.
func FinalizeProgramRevision ¶
func FinalizeProgramRevision(fc types.FileContract, burn types.Currency) (types.FileContract, error)
FinalizeProgramRevision returns a new file contract revision with the burn amount subtracted from the host output. The revision number is incremented.
func InstructionRequiresContract ¶
func InstructionRequiresContract(i Instruction) bool
InstructionRequiresContract returns true if the instruction requires a contract to be locked.
func InstructionRequiresFinalization ¶
func InstructionRequiresFinalization(i Instruction) bool
InstructionRequiresFinalization returns true if the instruction results need to be committed to a contract.
func PaymentRevision ¶
func PaymentRevision(fc types.FileContract, amount types.Currency) (types.FileContract, error)
PaymentRevision returns a new file contract revision with the specified amount moved from the renter's payout to the host's payout (both valid and missed). The revision number is incremented.
func ProofSize ¶
ProofSize returns the size of a Merkle proof for the leaf i within a tree containing n leaves.
func RPCReadRenterCost ¶
func RPCReadRenterCost(settings HostSettings, sections []RPCReadRequestSection) types.Currency
RPCReadRenterCost computes the cost of a Read RPC.
func RPCWriteHostCollateral ¶
func RPCWriteHostCollateral(settings HostSettings, fc types.FileContract, actions []RPCWriteAction) types.Currency
RPCWriteHostCollateral computes the collateral for a Write RPC.
func RPCWriteRenterCost ¶
func RPCWriteRenterCost(settings HostSettings, fc types.FileContract, actions []RPCWriteAction) types.Currency
RPCWriteRenterCost computes the cost of a Write RPC.
func RangeProofSize ¶
RangeProofSize returns the size of a Merkle proof for the leaf range [start, end) within a tree containing n leaves.
func ReadSector ¶
ReadSector reads a single sector from r and calculates its root.
func ReaderRoot ¶
ReaderRoot returns the Merkle root of the supplied stream, which must contain an integer multiple of leaves.
func RegistryHostID ¶
RegistryHostID returns the ID hash of the host for primary registry entries.
func RegistryKey ¶
RegistryKey is the unique key for a RegistryValue.
func SectorRoot ¶
func SectorRoot(sector *[SectorSize]byte) types.Hash256
SectorRoot computes the Merkle root of a sector.
func ValidateContractFinalization ¶
func ValidateContractFinalization(current, final types.FileContract) error
ValidateContractFinalization verifies that the revision locks the current contract by setting its revision number to the maximum legal value. No other fields should change. Signatures are not validated.
func ValidateContractFormation ¶
func ValidateContractFormation(fc types.FileContract, currentHeight uint64, settings HostSettings) error
ValidateContractFormation verifies that the new contract is valid given the host's settings.
func ValidateContractRenewal ¶
func ValidateContractRenewal(existing, renewal types.FileContract, currentHeight uint64, settings HostSettings) error
ValidateContractRenewal verifies that the renewed contract is valid given the old contract. A renewal is valid if the contract fields match and the revision number is 0.
func ValidateContractSignatures ¶
func ValidateContractSignatures(cs consensus.State, fc types.FileContract) (err error)
ValidateContractSignatures validates a contract's renter and host signatures.
func ValidatePaymentRevision ¶
func ValidatePaymentRevision(current, revision types.FileContract, amount types.Currency) error
ValidatePaymentRevision verifies that a payment revision is valid and the amount is properly deducted from both renter outputs and added to both host outputs. Signatures are not validated.
func ValidateProgramRevision ¶
func ValidateProgramRevision(current, revision types.FileContract, additionalStorage, additionalCollateral types.Currency) error
ValidateProgramRevision verifies that a contract program revision is valid and only the missed host output value is modified by the expected burn amount all other usage will have been paid for by the RPC budget. Signatures are not validated.
func ValidateRegistryEntry ¶
func ValidateRegistryEntry(value RegistryValue) (err error)
ValidateRegistryEntry validates the fields of a registry entry.
func ValidateRegistryUpdate ¶
func ValidateRegistryUpdate(old, update RegistryValue, 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 Contract ¶
type Contract struct { ID types.ElementID Revision types.FileContract }
A Contract pairs a file contract with its ID.
func (*Contract) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
type ContractOutputs ¶
type ContractOutputs struct { RenterValue types.Currency HostValue types.Currency MissedHostValue types.Currency }
ContractOutputs contains the output values for a FileContract. Because the revisions negotiated by the renter and host typically do not modify the output recipients, we can save some space by only sending the new values.
func (ContractOutputs) Apply ¶
func (co ContractOutputs) Apply(fc *types.FileContract)
Apply sets the output values of fc according to co.
type HostSettings ¶
type HostSettings struct { AcceptingContracts bool `json:"acceptingContracts"` Address types.Address `json:"address"` BlockHeight uint64 `json:"blockHeight"` EphemeralAccountExpiry time.Duration `json:"ephemeralAccountExpiry"` MaxCollateral types.Currency `json:"maxCollateral"` MaxDuration uint64 `json:"maxDuration"` MaxEphemeralAccountBalance types.Currency `json:"maxEphemeralAccountBalance"` NetAddress string `json:"netAddress"` RemainingRegistryEntries uint64 `json:"remainingRegistryEntries"` RemainingStorage uint64 `json:"remainingStorage"` SectorSize uint64 `json:"sectorSize"` TotalRegistryEntries uint64 `json:"totalRegistryEntries"` TotalStorage uint64 `json:"totalStorage"` ValidUntil time.Time `json:"validUntil"` Version string `json:"version"` WindowSize uint64 `json:"windowSize"` ContractFee types.Currency `json:"contractFee"` // Collateral is the amount of Hastings per byte per block that the host is willing to risk. Collateral types.Currency `json:"collateral"` // DownloadBandwidthPrice is the amount of Hastings per byte of download data charged to the renter. DownloadBandwidthPrice types.Currency `json:"downloadBandwidthPrice"` // UploadBandwidthPrice is the amount of Hastings per byte of upload data charged to the renter. UploadBandwidthPrice types.Currency `json:"uploadBandwidthPrice"` // StoragePrice is the amount of Hastings per byte per block to store data on the host. StoragePrice types.Currency `json:"storagePrice"` RPCAccountBalanceCost types.Currency `json:"rpcAccountBalanceCost"` RPCFundAccountCost types.Currency `json:"rpcFundAccountCost"` RPCHostSettingsCost types.Currency `json:"rpcHostSettingsCost"` RPCLatestRevisionCost types.Currency `json:"rpcLatestRevisionCost"` RPCRenewContractCost types.Currency `json:"rpcRenewContractCost"` // ProgInitBaseCost is the cost in Hastings 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 ProgInitBaseCost types.Currency `json:"progInitBaseCost"` // ProgMemoryTimeCost is the cost in Hastings per byte per time that is // incurred by the memory consumption of the program. ProgMemoryTimeCost types.Currency `json:"progMemorytimecost"` // ProgReadCost is the cost in Hastings per byte of data read from disk during program executions. ProgReadCost types.Currency `json:"progReadCost"` // ProgWriteCost is the cost in Hastings per byte, rounded up to the nearest multiple of 4KiB, of data written to // disk during program execution. ProgWriteCost types.Currency `json:"progWriteCost"` InstrAppendSectorBaseCost types.Currency `json:"instrAppendSectorsBaseCost"` InstrDropSectorsBaseCost types.Currency `json:"instrDropSectorsBaseCost"` InstrDropSectorsUnitCost types.Currency `json:"instrDropSectorsUnitCost"` InstrHasSectorBaseCost types.Currency `json:"instrHasSectorBaseCost"` InstrReadBaseCost types.Currency `json:"instrReadBaseCost"` InstrReadRegistryBaseCost types.Currency `json:"instrReadRegistryBaseCost"` InstrRevisionBaseCost types.Currency `json:"instrRevisionBaseCost"` InstrSectorRootsBaseCost types.Currency `json:"instrSectorRootsBaseCost"` InstrSwapSectorBaseCost types.Currency `json:"instrSwapSectorCost"` InstrUpdateRegistryBaseCost types.Currency `json:"instrUpdateRegistryBaseCost"` InstrUpdateSectorBaseCost types.Currency `json:"instrUpdateSectorBaseCost"` InstrWriteBaseCost types.Currency `json:"instrWriteBaseCost"` }
HostSettings are the settings and prices used when interacting with a host.
func (*HostSettings) DecodeFrom ¶
func (p *HostSettings) DecodeFrom(d *types.Decoder)
DecodeFrom decodes host settings from the decoder; implements types.DecoderFrom.
func (*HostSettings) EncodeTo ¶
func (p *HostSettings) EncodeTo(e *types.Encoder)
EncodeTo encodes host settings to the encoder; implements types.EncoderTo.
type InstrAppendSector ¶
InstrAppendSector uploads and appends a new sector to a contract
func (*InstrAppendSector) DecodeFrom ¶
func (i *InstrAppendSector) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrAppendSector) EncodeTo ¶
func (i *InstrAppendSector) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrAppendSector) MaxLen ¶
func (i *InstrAppendSector) MaxLen() int
MaxLen implements rpc.Object
type InstrContractRevision ¶
type InstrContractRevision struct { }
InstrContractRevision returns the latest revision of the program's contract.
func (*InstrContractRevision) DecodeFrom ¶
func (i *InstrContractRevision) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrContractRevision) EncodeTo ¶
func (i *InstrContractRevision) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrContractRevision) MaxLen ¶
func (i *InstrContractRevision) MaxLen() int
MaxLen implements rpc.Object
type InstrDropSectors ¶
InstrDropSectors deletes a number of sectors from the end of the contract.
func (*InstrDropSectors) DecodeFrom ¶
func (i *InstrDropSectors) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrDropSectors) EncodeTo ¶
func (i *InstrDropSectors) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrDropSectors) MaxLen ¶
func (i *InstrDropSectors) MaxLen() int
MaxLen implements rpc.Object
type InstrHasSector ¶
type InstrHasSector struct {
SectorRootOffset uint64
}
InstrHasSector returns true if the host has the given sector.
func (*InstrHasSector) DecodeFrom ¶
func (i *InstrHasSector) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrHasSector) EncodeTo ¶
func (i *InstrHasSector) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
type InstrReadOffset ¶
InstrReadOffset reads len bytes from the contract at the given offset.
func (*InstrReadOffset) DecodeFrom ¶
func (i *InstrReadOffset) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrReadOffset) EncodeTo ¶
func (i *InstrReadOffset) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrReadOffset) MaxLen ¶
func (i *InstrReadOffset) MaxLen() int
MaxLen implements rpc.Object
type InstrReadRegistry ¶
InstrReadRegistry reads the given registry key from the contract.
func (*InstrReadRegistry) DecodeFrom ¶
func (i *InstrReadRegistry) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrReadRegistry) EncodeTo ¶
func (i *InstrReadRegistry) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrReadRegistry) MaxLen ¶
func (i *InstrReadRegistry) MaxLen() int
MaxLen implements rpc.Object
type InstrReadSector ¶
type InstrReadSector struct { RootOffset uint64 SectorOffset uint64 LengthOffset uint64 ProofRequired bool }
InstrReadSector reads offset and len bytes of the sector.
func (*InstrReadSector) DecodeFrom ¶
func (i *InstrReadSector) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrReadSector) EncodeTo ¶
func (i *InstrReadSector) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrReadSector) MaxLen ¶
func (i *InstrReadSector) MaxLen() int
MaxLen implements rpc.Object
type InstrSectorRoots ¶
type InstrSectorRoots struct { }
InstrSectorRoots returns the program's sector roots
func (*InstrSectorRoots) DecodeFrom ¶
func (i *InstrSectorRoots) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrSectorRoots) EncodeTo ¶
func (i *InstrSectorRoots) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrSectorRoots) MaxLen ¶
func (i *InstrSectorRoots) MaxLen() int
MaxLen implements rpc.Object
type InstrSwapSector ¶
InstrSwapSector swaps two sectors by root in the contract.
func (*InstrSwapSector) DecodeFrom ¶
func (i *InstrSwapSector) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrSwapSector) EncodeTo ¶
func (i *InstrSwapSector) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrSwapSector) MaxLen ¶
func (i *InstrSwapSector) MaxLen() int
MaxLen implements rpc.Object
type InstrUpdateRegistry ¶
type InstrUpdateRegistry struct {
EntryOffset uint64
}
InstrUpdateRegistry updates a registry entry.
func (*InstrUpdateRegistry) DecodeFrom ¶
func (i *InstrUpdateRegistry) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrUpdateRegistry) EncodeTo ¶
func (i *InstrUpdateRegistry) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrUpdateRegistry) MaxLen ¶
func (i *InstrUpdateRegistry) MaxLen() int
MaxLen implements rpc.Object
type InstrUpdateSector ¶
InstrUpdateSector uploads and appends a new sector to a contract
func (*InstrUpdateSector) DecodeFrom ¶
func (i *InstrUpdateSector) DecodeFrom(d *types.Decoder)
DecodeFrom decodes an instruction from the provided decoder. Implements rpc.Object.
func (*InstrUpdateSector) EncodeTo ¶
func (i *InstrUpdateSector) EncodeTo(e *types.Encoder)
EncodeTo encodes an instruction to the provided encoder. Implements rpc.Object.
func (*InstrUpdateSector) MaxLen ¶
func (i *InstrUpdateSector) MaxLen() int
MaxLen implements rpc.Object
type Instruction ¶
An Instruction is a single instruction in an MDM program.
type PayByContractRequest ¶
type PayByContractRequest struct { ContractID types.ElementID RefundAccount types.PublicKey Signature types.Signature NewRevisionNumber uint64 NewOutputs ContractOutputs }
PayByContractRequest is a request to create an RPC budget using funds from a file contract.
func (*PayByContractRequest) DecodeFrom ¶
func (req *PayByContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (*PayByContractRequest) EncodeTo ¶
func (req *PayByContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
func (*PayByContractRequest) MaxLen ¶
func (req *PayByContractRequest) MaxLen() int
MaxLen implements rpc.Object.
type PayByEphemeralAccountRequest ¶
type PayByEphemeralAccountRequest struct { Message WithdrawalMessage Signature types.Signature Priority uint64 }
PayByEphemeralAccountRequest is a request to create an RPC budget using funds from an ephemeral account.
func (*PayByEphemeralAccountRequest) DecodeFrom ¶
func (req *PayByEphemeralAccountRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (*PayByEphemeralAccountRequest) EncodeTo ¶
func (req *PayByEphemeralAccountRequest) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
func (*PayByEphemeralAccountRequest) MaxLen ¶
func (req *PayByEphemeralAccountRequest) MaxLen() int
MaxLen implements rpc.Object.
type ProgramBuilder ¶
type ProgramBuilder struct {
// contains filtered or unexported fields
}
A ProgramBuilder constructs MDM programs for the renter to execute on a host.
func NewProgramBuilder ¶
func NewProgramBuilder(settings HostSettings, data *bytes.Buffer, duration uint64) *ProgramBuilder
NewProgramBuilder initializes a new empty ProgramBuilder.
func (*ProgramBuilder) AddAppendSectorInstruction ¶
func (pb *ProgramBuilder) AddAppendSectorInstruction(sector *[SectorSize]byte, proof bool)
AddAppendSectorInstruction adds an append sector instruction to the program.
func (*ProgramBuilder) AddDropSectorInstruction ¶
func (pb *ProgramBuilder) AddDropSectorInstruction(sectors uint64, proof bool)
AddDropSectorInstruction adds a drop sector instruction to the program.
func (*ProgramBuilder) AddDropSectorsInstruction ¶
func (pb *ProgramBuilder) AddDropSectorsInstruction(sectors uint64, proof bool)
AddDropSectorsInstruction adds a drop sectors instruction to the program.
func (*ProgramBuilder) AddHasSectorInstruction ¶
func (pb *ProgramBuilder) AddHasSectorInstruction(root types.Hash256)
AddHasSectorInstruction adds a has sector instruction to the program.
func (*ProgramBuilder) AddReadOffsetInstruction ¶
func (pb *ProgramBuilder) AddReadOffsetInstruction(offset, length uint64, proof bool)
AddReadOffsetInstruction adds a read offset instruction to the program.
func (*ProgramBuilder) AddReadRegistryInstruction ¶
func (pb *ProgramBuilder) AddReadRegistryInstruction(pub types.PublicKey, tweak types.Hash256)
AddReadRegistryInstruction adds a read registry instruction to the program.
func (*ProgramBuilder) AddReadSectorInstruction ¶
func (pb *ProgramBuilder) AddReadSectorInstruction(root types.Hash256, offset uint64, length uint64, proof bool) error
AddReadSectorInstruction adds a read sector instruction to the program.
func (*ProgramBuilder) AddRevisionInstruction ¶
func (pb *ProgramBuilder) AddRevisionInstruction()
AddRevisionInstruction adds a revision instruction to the program.
func (*ProgramBuilder) AddSectorRootsInstruction ¶
func (pb *ProgramBuilder) AddSectorRootsInstruction(sectors uint64)
AddSectorRootsInstruction adds a contract roots instruction to the program, returning the Merkle root of each sector stored by the contract.
func (*ProgramBuilder) AddSwapSectorInstruction ¶
func (pb *ProgramBuilder) AddSwapSectorInstruction(i, j uint64, proof bool)
AddSwapSectorInstruction adds a swap sector instruction to the program.
func (*ProgramBuilder) AddUpdateRegistryInstruction ¶
func (pb *ProgramBuilder) AddUpdateRegistryInstruction(value RegistryValue)
AddUpdateRegistryInstruction adds an update registry instruction to the program.
func (*ProgramBuilder) AddUpdateSectorInstruction ¶
func (pb *ProgramBuilder) AddUpdateSectorInstruction(offset uint64, data []byte, proof bool) error
AddUpdateSectorInstruction adds an update sector instruction to the program.
func (*ProgramBuilder) Cost ¶
func (pb *ProgramBuilder) Cost() ResourceUsage
Cost returns the estimated cost of executing the program, excluding bandwidth usage.
func (*ProgramBuilder) Program ¶
func (pb *ProgramBuilder) Program() (instructions []Instruction, requiresContract, requiresFinalization bool, err error)
Program returns the program's instructions and a bool indicating if the program is read-only.
type RPCAccountBalanceRequest ¶
RPCAccountBalanceRequest is a request for the balance of an account.
func (*RPCAccountBalanceRequest) DecodeFrom ¶
func (resp *RPCAccountBalanceRequest) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCAccountBalanceRequest from a decoder. Implements types.DecoderFrom.
func (*RPCAccountBalanceRequest) EncodeTo ¶
func (resp *RPCAccountBalanceRequest) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCAccountBalanceRequest to an encoder. Implements types.EncoderTo.
func (*RPCAccountBalanceRequest) MaxLen ¶
func (resp *RPCAccountBalanceRequest) MaxLen() int
MaxLen returns the maximum length of the encoded object. Implements rpc.Object.
type RPCAccountBalanceResponse ¶
RPCAccountBalanceResponse is the returned response for RPCAccountBalance.
func (*RPCAccountBalanceResponse) DecodeFrom ¶
func (resp *RPCAccountBalanceResponse) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCAccountBalanceResponse from a decoder. Implements types.DecoderFrom.
func (*RPCAccountBalanceResponse) EncodeTo ¶
func (resp *RPCAccountBalanceResponse) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCAccountBalanceResponse to an encoder. Implements types.EncoderTo.
func (*RPCAccountBalanceResponse) MaxLen ¶
func (resp *RPCAccountBalanceResponse) MaxLen() int
MaxLen returns the maximum length of the encoded object. Implements rpc.Object.
type RPCContractSignatures ¶
RPCContractSignatures contains the siacoin input signatures for a transaction. These signatures are sent by the renter and host during contract formation.
func (*RPCContractSignatures) DecodeFrom ¶
func (r *RPCContractSignatures) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCContractSignatures) EncodeTo ¶
func (r *RPCContractSignatures) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCContractSignatures) MaxLen ¶
func (r *RPCContractSignatures) MaxLen() int
MaxLen implements rpc.Object.
type RPCExecuteInstrResponse ¶
type RPCExecuteInstrResponse struct { AdditionalCollateral types.Currency AdditionalStorage types.Currency FailureRefund types.Currency TotalCost types.Currency OutputLength uint64 NewDataSize uint64 NewMerkleRoot types.Hash256 Proof []types.Hash256 Error error }
RPCExecuteInstrResponse is sent to the renter by the host for each successfully executed instruction during program execution. The final response is used to determine the final contract state.
func (*RPCExecuteInstrResponse) DecodeFrom ¶
func (resp *RPCExecuteInstrResponse) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCExecuteInstrResponse from a decoder. Implements types.DecoderFrom.
func (*RPCExecuteInstrResponse) EncodeTo ¶
func (resp *RPCExecuteInstrResponse) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCExecuteInstrResponse to an encoder. Implements types.EncoderTo.
func (*RPCExecuteInstrResponse) MaxLen ¶
func (resp *RPCExecuteInstrResponse) MaxLen() int
MaxLen returns the maximum length of the encoded object. Implements rpc.Object.
type RPCExecuteProgramRequest ¶
type RPCExecuteProgramRequest struct { // FileContractID is the id of the filecontract we would like to modify. FileContractID types.ElementID // RenterSignature is the signature of the last revision of the file // contract. RenterSignature types.Signature // Instructions are the instructions to be executed. Instructions []Instruction // ProgramDataLength is the length of the programData following this // request. ProgramDataLength uint64 }
RPCExecuteProgramRequest is the request for the RPC method "execute".
func (*RPCExecuteProgramRequest) DecodeFrom ¶
func (req *RPCExecuteProgramRequest) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCExecuteProgramRequest from a decoder. Implements types.DecoderFrom.
func (*RPCExecuteProgramRequest) EncodeTo ¶
func (req *RPCExecuteProgramRequest) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCExecuteProgramRequest to an encoder. Implements types.EncoderTo.
func (*RPCExecuteProgramRequest) MaxLen ¶
func (req *RPCExecuteProgramRequest) MaxLen() int
MaxLen returns the maximum encoded length of an object. Implements rpc.Object.
type RPCFinalizeProgramRequest ¶
type RPCFinalizeProgramRequest struct { Signature types.Signature NewRevisionNumber uint64 NewOutputs ContractOutputs }
RPCFinalizeProgramRequest is a request sent by the renter after execution of a read-write program to update the contract with the new collateral and storage burn.
func (*RPCFinalizeProgramRequest) DecodeFrom ¶
func (req *RPCFinalizeProgramRequest) DecodeFrom(d *types.Decoder)
DecodeFrom decodes the RPCFinalizeProgramRequest from the decoder. Implements types.DecoderFrom.
func (*RPCFinalizeProgramRequest) EncodeTo ¶
func (req *RPCFinalizeProgramRequest) EncodeTo(e *types.Encoder)
EncodeTo encodes the RPCFinalizeProgramRequest to the encoder. Implements types.EncoderTo.
func (*RPCFinalizeProgramRequest) MaxLen ¶
func (req *RPCFinalizeProgramRequest) MaxLen() int
MaxLen returns the maximum encoded size of the object; implements rpc.Object.
type RPCFormContractHostAdditions ¶
type RPCFormContractHostAdditions struct { Inputs []types.SiacoinInput Outputs []types.SiacoinOutput ContractSignature types.Signature }
RPCFormContractHostAdditions contains the parent transaction, inputs, outputs and contract signature added by the host when negotiating a file contract. It is expected that the inputs are not signed yet.
func (*RPCFormContractHostAdditions) DecodeFrom ¶
func (r *RPCFormContractHostAdditions) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCFormContractHostAdditions) EncodeTo ¶
func (r *RPCFormContractHostAdditions) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCFormContractHostAdditions) MaxLen ¶
func (r *RPCFormContractHostAdditions) MaxLen() int
MaxLen implements rpc.Object.
type RPCFormContractRequest ¶
type RPCFormContractRequest struct { Inputs []types.SiacoinInput Outputs []types.SiacoinOutput MinerFee types.Currency Contract types.FileContract }
RPCFormContractRequest contains the request parameters for the FormContract RPC.
func (*RPCFormContractRequest) DecodeFrom ¶
func (r *RPCFormContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCFormContractRequest) EncodeTo ¶
func (r *RPCFormContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCFormContractRequest) MaxLen ¶
func (r *RPCFormContractRequest) MaxLen() int
MaxLen implements rpc.Object.
type RPCFundAccountRequest ¶
RPCFundAccountRequest is a request to fund an account.
func (*RPCFundAccountRequest) DecodeFrom ¶
func (resp *RPCFundAccountRequest) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCFundAccountRequest from a decoder. Implements types.DecoderFrom.
func (*RPCFundAccountRequest) EncodeTo ¶
func (resp *RPCFundAccountRequest) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCFundAccountRequest to an encoder. Implements types.EncoderTo.
func (*RPCFundAccountRequest) MaxLen ¶
func (resp *RPCFundAccountRequest) MaxLen() int
MaxLen returns the maximum length of the encoded object. Implements rpc.Object.
type RPCFundAccountResponse ¶
type RPCFundAccountResponse struct { Balance types.Currency Receipt Receipt Signature types.Signature }
RPCFundAccountResponse is the response to a RPCFundAccountRequest. It returns the current balance of the account and a signed receipt from the host.
func (*RPCFundAccountResponse) DecodeFrom ¶
func (resp *RPCFundAccountResponse) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCFundAccountResponse from a decoder. Implements types.DecoderFrom.
func (*RPCFundAccountResponse) EncodeTo ¶
func (resp *RPCFundAccountResponse) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCFundAccountResponse to an encoder. Implements types.EncoderTo.
func (*RPCFundAccountResponse) MaxLen ¶
func (resp *RPCFundAccountResponse) MaxLen() int
MaxLen returns the maximum length of the encoded object. Implements rpc.Object.
type RPCLatestRevisionRequest ¶
RPCLatestRevisionRequest requests the host send the latest revision of the contract.
func (*RPCLatestRevisionRequest) DecodeFrom ¶
func (r *RPCLatestRevisionRequest) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCLatestRevisionRequest from a decoder. Implements types.DecoderFrom.
func (*RPCLatestRevisionRequest) EncodeTo ¶
func (r *RPCLatestRevisionRequest) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCLatestRevisionRequest to an encoder. Implements types.EncoderTo.
func (*RPCLatestRevisionRequest) MaxLen ¶
func (r *RPCLatestRevisionRequest) MaxLen() int
MaxLen returns the maximum encoded length of an object. Implements rpc.Object.
type RPCLatestRevisionResponse ¶
type RPCLatestRevisionResponse struct {
Revision Contract
}
RPCLatestRevisionResponse contains the latest revision of a contract from the host.
func (*RPCLatestRevisionResponse) DecodeFrom ¶
func (r *RPCLatestRevisionResponse) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCLatestRevisionResponse from a decoder. Implements types.DecoderFrom.
func (*RPCLatestRevisionResponse) EncodeTo ¶
func (r *RPCLatestRevisionResponse) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCLatestRevisionResponse to an encoder. Implements types.EncoderTo.
func (*RPCLatestRevisionResponse) MaxLen ¶
func (r *RPCLatestRevisionResponse) MaxLen() int
MaxLen returns the maximum encoded length of an object. Implements rpc.Object.
type RPCLockRequest ¶
RPCLockRequest contains the request parameters for the Lock RPC.
func (*RPCLockRequest) DecodeFrom ¶
func (r *RPCLockRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCLockRequest) EncodeTo ¶
func (r *RPCLockRequest) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
type RPCLockResponse ¶
type RPCLockResponse struct { Acquired bool NewChallenge [16]byte Revision types.FileContract }
RPCLockResponse contains the response data for the Lock RPC.
func (*RPCLockResponse) DecodeFrom ¶
func (r *RPCLockResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCLockResponse) EncodeTo ¶
func (r *RPCLockResponse) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCLockResponse) MaxLen ¶
func (r *RPCLockResponse) MaxLen() int
MaxLen implements rpc.Object.
type RPCReadRequest ¶
type RPCReadRequest struct { Sections []RPCReadRequestSection MerkleProof bool NewRevisionNumber uint64 NewOutputs ContractOutputs Signature types.Signature }
RPCReadRequest contains the request parameters for the Read RPC.
func (*RPCReadRequest) DecodeFrom ¶
func (r *RPCReadRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCReadRequest) EncodeTo ¶
func (r *RPCReadRequest) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
type RPCReadRequestSection ¶
RPCReadRequestSection is a section requested in RPCReadRequest.
type RPCReadResponse ¶
RPCReadResponse contains the response data for the Read RPC.
func (*RPCReadResponse) DecodeFrom ¶
func (r *RPCReadResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCReadResponse) EncodeTo ¶
func (r *RPCReadResponse) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCReadResponse) MaxLen ¶
func (r *RPCReadResponse) MaxLen() int
MaxLen implements rpc.Object.
type RPCRenewContractHostAdditions ¶
type RPCRenewContractHostAdditions struct { Inputs []types.SiacoinInput Outputs []types.SiacoinOutput HostRollover types.Currency FinalizationSignature types.Signature InitialSignature types.Signature RenewalSignature types.Signature }
RPCRenewContractHostAdditions contains the parent transaction, inputs, outputs, finalization and renewal signatures added by the host when negotiating a contract renewal. It is expected that the inputs are not signed yet.
func (*RPCRenewContractHostAdditions) DecodeFrom ¶
func (r *RPCRenewContractHostAdditions) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCRenewContractHostAdditions) EncodeTo ¶
func (r *RPCRenewContractHostAdditions) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCRenewContractHostAdditions) MaxLen ¶
func (r *RPCRenewContractHostAdditions) MaxLen() int
MaxLen implements rpc.Object.
type RPCRenewContractRenterSignatures ¶
type RPCRenewContractRenterSignatures struct { SiacoinInputSignatures [][]types.Signature RenewalSignature types.Signature }
RPCRenewContractRenterSignatures contains the siacoin input and renewal signature for a transaction. These signatures are sent by the renter during contract renewal.
func (*RPCRenewContractRenterSignatures) DecodeFrom ¶
func (r *RPCRenewContractRenterSignatures) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCRenewContractRenterSignatures) EncodeTo ¶
func (r *RPCRenewContractRenterSignatures) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCRenewContractRenterSignatures) MaxLen ¶
func (r *RPCRenewContractRenterSignatures) MaxLen() int
MaxLen implements rpc.Object.
type RPCRenewContractRequest ¶
type RPCRenewContractRequest struct { Inputs []types.SiacoinInput Outputs []types.SiacoinOutput MinerFee types.Currency Resolution types.FileContractResolution }
RPCRenewContractRequest contains the request parameters for the Renew RPC. Resolution must contain a valid contract renewal.
func (*RPCRenewContractRequest) DecodeFrom ¶
func (r *RPCRenewContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCRenewContractRequest) EncodeTo ¶
func (r *RPCRenewContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCRenewContractRequest) MaxLen ¶
func (r *RPCRenewContractRequest) MaxLen() int
MaxLen implements rpc.Object.
type RPCRevisionSigningResponse ¶
RPCRevisionSigningResponse is returned by the host when finalizing a contract revision.
func (*RPCRevisionSigningResponse) DecodeFrom ¶
func (resp *RPCRevisionSigningResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (*RPCRevisionSigningResponse) EncodeTo ¶
func (resp *RPCRevisionSigningResponse) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
func (*RPCRevisionSigningResponse) MaxLen ¶
func (resp *RPCRevisionSigningResponse) MaxLen() int
MaxLen implements rpc.Object.
type RPCSectorRootsRequest ¶
type RPCSectorRootsRequest struct { RootOffset uint64 NumRoots uint64 NewRevisionNumber uint64 NewOutputs ContractOutputs Signature types.Signature }
RPCSectorRootsRequest contains the request parameters for the SectorRoots RPC.
func (*RPCSectorRootsRequest) DecodeFrom ¶
func (r *RPCSectorRootsRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCSectorRootsRequest) EncodeTo ¶
func (r *RPCSectorRootsRequest) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCSectorRootsRequest) MaxLen ¶
func (r *RPCSectorRootsRequest) MaxLen() int
MaxLen implements rpc.Object.
type RPCSectorRootsResponse ¶
type RPCSectorRootsResponse struct { Signature types.Signature SectorRoots []types.Hash256 MerkleProof []types.Hash256 }
RPCSectorRootsResponse contains the response data for the SectorRoots RPC.
func (*RPCSectorRootsResponse) DecodeFrom ¶
func (r *RPCSectorRootsResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCSectorRootsResponse) EncodeTo ¶
func (r *RPCSectorRootsResponse) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCSectorRootsResponse) MaxLen ¶
func (r *RPCSectorRootsResponse) MaxLen() int
MaxLen implements rpc.Object.
type RPCSettingsRegisteredResponse ¶
type RPCSettingsRegisteredResponse struct {
ID SettingsID
}
RPCSettingsRegisteredResponse returns the settings ID to the renter to signal success.
func (*RPCSettingsRegisteredResponse) DecodeFrom ¶
func (r *RPCSettingsRegisteredResponse) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCSettingsRegisteredResponse from a decoder. Implements types.DecoderFrom.
func (*RPCSettingsRegisteredResponse) EncodeTo ¶
func (r *RPCSettingsRegisteredResponse) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCSettingsRegisteredResponse to an encoder. Implements types.EncoderTo.
func (*RPCSettingsRegisteredResponse) MaxLen ¶
func (r *RPCSettingsRegisteredResponse) MaxLen() int
MaxLen returns the maximum encoded length of an object. Implements rpc.Object.
type RPCSettingsResponse ¶
type RPCSettingsResponse struct {
Settings []byte
}
RPCSettingsResponse contains the JSON-encoded settings for a host.
func (*RPCSettingsResponse) DecodeFrom ¶
func (r *RPCSettingsResponse) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a RPCSettingsResponse from a decoder. Implements types.DecoderFrom.
func (*RPCSettingsResponse) EncodeTo ¶
func (r *RPCSettingsResponse) EncodeTo(e *types.Encoder)
EncodeTo encodes a RPCSettingsResponse to an encoder. Implements types.EncoderTo.
func (*RPCSettingsResponse) MaxLen ¶
func (r *RPCSettingsResponse) MaxLen() int
MaxLen returns the maximum encoded length of an object. Implements rpc.Object.
type RPCWriteAction ¶
RPCWriteAction is a generic Write action. The meaning of each field depends on the Type of the action.
func (*RPCWriteAction) DecodeFrom ¶
func (r *RPCWriteAction) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCWriteAction) EncodeTo ¶
func (r *RPCWriteAction) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
type RPCWriteMerkleProof ¶
type RPCWriteMerkleProof struct { OldSubtreeHashes []types.Hash256 OldLeafHashes []types.Hash256 NewMerkleRoot types.Hash256 }
RPCWriteMerkleProof contains the optional Merkle proof for response data for the Write RPC.
func (*RPCWriteMerkleProof) DecodeFrom ¶
func (r *RPCWriteMerkleProof) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCWriteMerkleProof) EncodeTo ¶
func (r *RPCWriteMerkleProof) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCWriteMerkleProof) MaxLen ¶
func (r *RPCWriteMerkleProof) MaxLen() int
MaxLen implements rpc.Object.
type RPCWriteRequest ¶
type RPCWriteRequest struct { Actions []RPCWriteAction MerkleProof bool NewRevisionNumber uint64 NewOutputs ContractOutputs }
RPCWriteRequest contains the request parameters for the Write RPC.
func (*RPCWriteRequest) DecodeFrom ¶
func (r *RPCWriteRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCWriteRequest) EncodeTo ¶
func (r *RPCWriteRequest) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCWriteRequest) MaxLen ¶
func (r *RPCWriteRequest) MaxLen() int
MaxLen implements rpc.Object.
type RPCWriteResponse ¶
RPCWriteResponse contains the response data for the Write RPC.
func (*RPCWriteResponse) DecodeFrom ¶
func (r *RPCWriteResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements rpc.Object.
func (*RPCWriteResponse) EncodeTo ¶
func (r *RPCWriteResponse) EncodeTo(e *types.Encoder)
EncodeTo implements rpc.Object.
func (*RPCWriteResponse) MaxLen ¶
func (r *RPCWriteResponse) MaxLen() int
MaxLen implements rpc.Object.
type RangeProofVerifier ¶
type RangeProofVerifier struct {
// contains filtered or unexported fields
}
A RangeProofVerifier allows range proofs to be verified in streaming fashion.
func NewRangeProofVerifier ¶
func NewRangeProofVerifier(start, end uint64) *RangeProofVerifier
NewRangeProofVerifier returns a RangeProofVerifier for the sector range [start, end).
type Receipt ¶
type Receipt struct { Account types.PublicKey Host types.PublicKey Amount types.Currency Timestamp time.Time }
A Receipt is returned as part of funding an ephemeral account. It shows the amount deposited and the account.
func (*Receipt) DecodeFrom ¶
DecodeFrom decodes a Receipt from a decoder. Implements types.DecoderFrom.
type RegistryValue ¶
type RegistryValue struct { Tweak types.Hash256 Data []byte Revision uint64 Type uint8 PublicKey types.PublicKey Signature types.Signature }
A RegistryValue is stored in the host registry.
func (*RegistryValue) DecodeFrom ¶
func (r *RegistryValue) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a Value from a Decoder. Implements types.DecoderFrom.
func (*RegistryValue) EncodeTo ¶
func (r *RegistryValue) EncodeTo(e *types.Encoder)
EncodeTo encodes a Value to an Encoder. Implements types.EncoderTo.
func (*RegistryValue) Hash ¶
func (r *RegistryValue) Hash() types.Hash256
Hash returns the hash of the Value used for signing the entry.
func (*RegistryValue) Key ¶
func (r *RegistryValue) Key() types.Hash256
Key returns the key for the registry value.
func (*RegistryValue) MaxLen ¶
func (r *RegistryValue) MaxLen() int
MaxLen returns the maximum length of an encoded Value. Implements rpc.Object.
func (*RegistryValue) Work ¶
func (r *RegistryValue) Work() types.Work
Work returns the work of a Value.
type ResourceUsage ¶
type ResourceUsage struct { // BaseCost is the cost to execute the instruction and includes // resource costs like memory and time. BaseCost types.Currency // StorageCost cost is charged after successful completion // of the instruction and should be refunded if the program fails. StorageCost types.Currency // AdditionalCollateral cost is the additional collateral the host should // add during program finalization AdditionalCollateral types.Currency Memory uint64 Time uint64 }
ResourceUsage is the associated costs of executing an instruction set or individual instruction.
func AppendSectorCost ¶
func AppendSectorCost(settings HostSettings, duration uint64) (costs ResourceUsage)
AppendSectorCost returns the cost of the append sector instruction.
func DropSectorsCost ¶
func DropSectorsCost(settings HostSettings, n uint64) (costs ResourceUsage)
DropSectorsCost returns the cost of the drop sectors instruction.
func ExecutionCost ¶
func ExecutionCost(settings HostSettings, data, instructions uint64, requiresFinalization bool) (costs ResourceUsage)
ExecutionCost returns the cost of initializing and, optionally, finalizing a program.
func HasSectorCost ¶
func HasSectorCost(settings HostSettings) (costs ResourceUsage)
HasSectorCost returns the cost of the has sector instruction.
func ReadCost ¶
func ReadCost(settings HostSettings, l uint64) (costs ResourceUsage)
ReadCost returns the cost of the read instruction.
func ReadRegistryCost ¶
func ReadRegistryCost(settings HostSettings) (costs ResourceUsage)
ReadRegistryCost returns the cost of the read registry instruction.
func RevisionCost ¶
func RevisionCost(settings HostSettings) (costs ResourceUsage)
RevisionCost returns the cost of the revision instruction.
func SectorRootsCost ¶
func SectorRootsCost(settings HostSettings, sectors uint64) (costs ResourceUsage)
SectorRootsCost returns the cost of executing the contract roots instruction.
func SwapSectorCost ¶
func SwapSectorCost(settings HostSettings) (costs ResourceUsage)
SwapSectorCost returns the cost of the swap sector instruction.
func UpdateRegistryCost ¶
func UpdateRegistryCost(settings HostSettings) (costs ResourceUsage)
UpdateRegistryCost returns the cost of the update registry instruction.
func UpdateSectorCost ¶
func UpdateSectorCost(settings HostSettings, l uint64) (costs ResourceUsage)
UpdateSectorCost returns the cost of the update instruction.
func (ResourceUsage) Add ¶
func (r ResourceUsage) Add(b ResourceUsage) (c ResourceUsage)
Add returns the sum of r and b.
type Session ¶
A Session is an ongoing exchange of RPCs via the renter-host protocol.
func AcceptSession ¶
AcceptSession conducts the host's half of the renter-host protocol handshake, returning a Session that can be used to handle RPC requests.
func DialSession ¶
DialSession conducts the renter's half of the renter-host protocol handshake, returning a Session that can be used to make RPC requests.
func (*Session) SetChallenge ¶
SetChallenge sets the current session challenge. Challenges allow the host to verify that a renter controls the contract signing key before allowing them to lock the contract.
func (*Session) SignChallenge ¶
func (s *Session) SignChallenge(priv types.PrivateKey) (sig types.Signature)
SignChallenge signs the current session challenge.
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 (id *SettingsID) DecodeFrom(d *types.Decoder)
DecodeFrom decodes a SettingsID from a decoder. Implements types.DecoderFrom.
func (*SettingsID) EncodeTo ¶
func (id *SettingsID) EncodeTo(e *types.Encoder)
EncodeTo encodes a SettingsID to an encoder. Implements types.EncoderTo.
func (*SettingsID) MaxLen ¶
func (id *SettingsID) MaxLen() int
MaxLen returns the maximum length of an encoded object. Implements rpc.Object.
type WithdrawalMessage ¶
type WithdrawalMessage struct { AccountID types.PublicKey Expiry uint64 Amount types.Currency // Nonce prevents duplicate withdrawals from being processed Nonce [8]byte }
WithdrawalMessage is the amount of money to deduct from the account to create the RPC budget.
func (*WithdrawalMessage) DecodeFrom ¶
func (wm *WithdrawalMessage) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (*WithdrawalMessage) EncodeTo ¶
func (wm *WithdrawalMessage) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
func (*WithdrawalMessage) MaxLen ¶
func (wm *WithdrawalMessage) MaxLen() int
MaxLen implements rpc.Object.
func (*WithdrawalMessage) SigHash ¶
func (wm *WithdrawalMessage) SigHash() types.Hash256
SigHash computes the hash of the withdrawal message used for signing the pay by ephemeral account request.