Documentation
¶
Index ¶
- Constants
- Variables
- func BuildAppendProof(sectorRoots, appended []types.Hash256) ([]types.Hash256, types.Hash256)
- func BuildFreeSectorsProof(sectorRoots []types.Hash256, freed []uint64) (treeHashes, leafHashes []types.Hash256)
- func BuildSectorProof(sector *[SectorSize]byte, start, end uint64) []types.Hash256
- func BuildSectorRootsProof(sectorRoots []types.Hash256, start, end uint64) []types.Hash256
- func ContractCost(cs consensus.State, p HostPrices, fc types.V2FileContract, ...) (renter, host types.Currency)
- func ErrorCode(err error) uint8
- func MetaRoot(roots []types.Hash256) types.Hash256
- func MinRenterAllowance(hp HostPrices, duration uint64, collateral types.Currency) types.Currency
- func NewRPCError(code uint8, desc string) error
- func PayWithContract(fc *types.V2FileContract, usage Usage) error
- func ReadID(r io.Reader) (id types.Specifier, err error)
- func ReadRequest(r io.Reader, o Object) error
- func ReadResponse(r io.Reader, o Object) error
- func ReadSector(r io.Reader) (types.Hash256, *[SectorSize]byte, error)
- func ReaderRoot(r io.Reader) (types.Hash256, error)
- func RefreshCost(cs consensus.State, p HostPrices, r types.V2FileContractRenewal, ...) (renter, host types.Currency)
- func RenewalCost(cs consensus.State, p HostPrices, r types.V2FileContractRenewal, ...) (renter, host types.Currency)
- func SectorRoot(sector *[SectorSize]byte) types.Hash256
- func VerifyAppendSectorsProof(numSectors uint64, subtreeRoots []types.Hash256, appended []types.Hash256, ...) bool
- func VerifyFreeSectorsProof(treeHashes, leafHashes []types.Hash256, freed []uint64, numSectors uint64, ...) bool
- func VerifyLeafProof(proof []types.Hash256, leaf [64]byte, leafIndex uint64, root types.Hash256) bool
- func VerifySectorRootsProof(proof, sectorRoots []types.Hash256, numSectors, start, end uint64, ...) bool
- func WriteRequest(w io.Writer, id types.Specifier, o Object) error
- func WriteResponse(w io.Writer, o Object) error
- type Account
- func (a *Account) DecodeFrom(d *types.Decoder)
- func (a Account) EncodeTo(e *types.Encoder)
- func (a Account) MarshalText() ([]byte, error)
- func (a Account) String() string
- func (a *Account) Token(renterKey types.PrivateKey, hostKey types.PublicKey) AccountToken
- func (a *Account) UnmarshalText(b []byte) error
- type AccountDeposit
- type AccountToken
- type HostPrices
- func (hp *HostPrices) DecodeFrom(d *types.Decoder)
- func (hp HostPrices) EncodeTo(e *types.Encoder)
- func (hp HostPrices) RPCAppendSectorsCost(sectors, duration uint64) Usage
- func (hp HostPrices) RPCFreeSectorsCost(sectors int) Usage
- func (hp HostPrices) RPCReadSectorCost(length uint64) Usage
- func (hp HostPrices) RPCSectorRootsCost(length uint64) Usage
- func (hp HostPrices) RPCVerifySectorCost() Usage
- func (hp HostPrices) RPCWriteSectorCost(sectorLength uint64) Usage
- func (hp HostPrices) SigHash() types.Hash256
- func (hp *HostPrices) Validate(pk types.PublicKey) error
- type HostSettings
- type Object
- type RPCAccountBalanceRequest
- type RPCAccountBalanceResponse
- type RPCAppendSectorsRequest
- type RPCAppendSectorsResponse
- type RPCAppendSectorsSecondResponse
- type RPCAppendSectorsThirdResponse
- type RPCError
- type RPCFormContractParams
- type RPCFormContractRequest
- type RPCFormContractResponse
- type RPCFormContractSecondResponse
- type RPCFormContractThirdResponse
- type RPCFreeSectorsRequest
- type RPCFreeSectorsResponse
- type RPCFreeSectorsSecondResponse
- type RPCFreeSectorsThirdResponse
- type RPCFundAccountsRequest
- type RPCFundAccountsResponse
- type RPCLatestRevisionRequest
- type RPCLatestRevisionResponse
- type RPCReadSectorRequest
- type RPCReadSectorResponse
- type RPCRefreshContractParams
- type RPCRefreshContractRequest
- func (r *RPCRefreshContractRequest) ChallengeSigHash(lastRevisionNumber uint64) types.Hash256
- func (r *RPCRefreshContractRequest) ValidChallengeSignature(existing types.V2FileContract) bool
- func (req *RPCRefreshContractRequest) Validate(pk types.PublicKey, existingTotalCollateral types.Currency, ...) error
- type RPCRefreshContractResponse
- type RPCRefreshContractSecondResponse
- type RPCRefreshContractThirdResponse
- type RPCRenewContractParams
- type RPCRenewContractRequest
- func (r *RPCRenewContractRequest) ChallengeSigHash(lastRevisionNumber uint64) types.Hash256
- func (r *RPCRenewContractRequest) ValidChallengeSignature(existing types.V2FileContract) bool
- func (req *RPCRenewContractRequest) Validate(pk types.PublicKey, tip types.ChainIndex, existingSize uint64, ...) error
- type RPCRenewContractResponse
- type RPCRenewContractSecondResponse
- type RPCRenewContractThirdResponse
- type RPCSectorRootsRequest
- type RPCSectorRootsResponse
- type RPCSettingsRequest
- type RPCSettingsResponse
- type RPCVerifySectorRequest
- type RPCVerifySectorResponse
- type RPCWriteSectorRequest
- type RPCWriteSectorResponse
- type RangeProofVerifier
- type Usage
- func NewContract(p HostPrices, cp RPCFormContractParams, hostKey types.PublicKey, ...) (types.V2FileContract, Usage)
- func RefreshContract(fc types.V2FileContract, prices HostPrices, rp RPCRefreshContractParams) (types.V2FileContractRenewal, Usage)
- func RenewContract(fc types.V2FileContract, prices HostPrices, rp RPCRenewContractParams) (types.V2FileContractRenewal, Usage)
- func ReviseForAppendSectors(fc types.V2FileContract, prices HostPrices, root types.Hash256, ...) (types.V2FileContract, Usage, error)
- func ReviseForFreeSectors(fc types.V2FileContract, prices HostPrices, newRoot types.Hash256, ...) (types.V2FileContract, Usage, error)
- func ReviseForFundAccounts(fc types.V2FileContract, amount types.Currency) (types.V2FileContract, Usage, error)
- func ReviseForSectorRoots(fc types.V2FileContract, prices HostPrices, numRoots uint64) (types.V2FileContract, Usage, error)
Constants ¶
const ( ErrorCodeTransport = iota + 1 ErrorCodeHostError ErrorCodeBadRequest ErrorCodeDecoding ErrorCodePayment )
Error codes.
const ( // LeafSize is the size of one leaf in bytes. LeafSize = rhp2.LeafSize // LeavesPerSector is the number of leaves in one sector. LeavesPerSector = rhp2.LeavesPerSector )
const ( // ProofWindow is the number of blocks a host has to submit a proof after // the contract expires. ProofWindow = 144 // 24 hours // TempSectorDuration is the number of blocks that temp sectors are expected to be stored // before being removed TempSectorDuration = 144 * 3 // MaxSectorBatchSize is the number of sector operations that can be batched into a single RPC. // For example, the number of sectors appended to a contract within a single RPC append call or the // number of sectors removed in a single RPC free call. MaxSectorBatchSize = (1 << 40) / (SectorSize) // SectorSize is the size of one sector in bytes. SectorSize = 1 << 22 // 4 MiB )
Variables ¶
var ( // ErrTokenExpired is returned when an account token has expired. ErrTokenExpired = NewRPCError(ErrorCodeBadRequest, "account token expired") // ErrPricesExpired is returned when the host's prices have expired. ErrPricesExpired = NewRPCError(ErrorCodeBadRequest, "prices expired") // ErrInvalidSignature is returned when a signature is invalid. ErrInvalidSignature = NewRPCError(ErrorCodeBadRequest, "invalid signature") // ErrNotEnoughFunds is returned when a client has insufficient funds to // pay for an RPC. ErrNotEnoughFunds = NewRPCError(ErrorCodePayment, "not enough funds") // ErrHostFundError is returned when the host encounters an error while // funding a formation or renewal transaction. ErrHostFundError = NewRPCError(ErrorCodeHostError, "host funding error") // ErrSectorNotFound is returned when the host is not storing a sector. ErrSectorNotFound = NewRPCError(ErrorCodeHostError, "sector not found") // ErrNotEnoughStorage is returned when the host does not have enough // storage to store a sector. ErrNotEnoughStorage = NewRPCError(ErrorCodeHostError, "not enough storage") // ErrHostInternalError is a catch-all for any error that occurs on the host // side and is not the client's fault. ErrHostInternalError = NewRPCError(ErrorCodeHostError, "internal error") )
var ( RPCAccountBalanceID = types.NewSpecifier("AccountBalance") RPCFormContractID = types.NewSpecifier("FormContract") RPCFundAccountsID = types.NewSpecifier("FundAccounts") RPCLatestRevisionID = types.NewSpecifier("LatestRevision") RPCAppendSectorsID = types.NewSpecifier("AppendSectors") RPCFreeSectorsID = types.NewSpecifier("FreeSectors") RPCReadSectorID = types.NewSpecifier("ReadSector") RPCRenewContractID = types.NewSpecifier("RenewContract") RPCRefreshContractID = types.NewSpecifier("RefreshContract") RPCSectorRootsID = types.NewSpecifier("SectorRoots") RPCSettingsID = types.NewSpecifier("Settings") RPCWriteSectorID = types.NewSpecifier("WriteSector") RPCVerifySectorID = types.NewSpecifier("VerifySector") )
RPC identifiers.
Functions ¶
func BuildAppendProof ¶
BuildAppendProof builds a Merkle proof for appending a set of sectors to a contract.
func BuildFreeSectorsProof ¶
func BuildFreeSectorsProof(sectorRoots []types.Hash256, freed []uint64) (treeHashes, leafHashes []types.Hash256)
BuildFreeSectorsProof builds a Merkle proof for freeing a set of sectors.
func BuildSectorProof ¶
func BuildSectorProof(sector *[SectorSize]byte, start, end uint64) []types.Hash256
BuildSectorProof builds a Merkle proof for a given range within a sector.
func BuildSectorRootsProof ¶
BuildSectorRootsProof builds a Merkle proof for a range of sectors within a contract.
func ContractCost ¶
func ContractCost(cs consensus.State, p HostPrices, fc types.V2FileContract, minerFee types.Currency) (renter, host types.Currency)
ContractCost calculates the cost to the host and renter for forming a contract.
func ErrorCode ¶
ErrorCode returns the code of err. If err is not an RPCError, ErrorCode returns ErrorCodeTransport.
func MinRenterAllowance ¶
MinRenterAllowance returns the minimum allowance required to justify the given host collateral.
func NewRPCError ¶
NewRPCError returns a new RPCError with the given code and description.
func PayWithContract ¶
func PayWithContract(fc *types.V2FileContract, usage Usage) error
PayWithContract modifies a contract to transfer the amount from the renter and deduct collateral from the host. It returns an RPC error if the contract does not have sufficient funds.
func ReadRequest ¶
ReadRequest reads a request from the stream.
func ReadResponse ¶
ReadResponse reads a response from the stream into r.
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 RefreshCost ¶
func RefreshCost(cs consensus.State, p HostPrices, r types.V2FileContractRenewal, minerFee types.Currency) (renter, host types.Currency)
RefreshCost calculates the cost to the host and renter for refreshing a contract.
func RenewalCost ¶
func RenewalCost(cs consensus.State, p HostPrices, r types.V2FileContractRenewal, minerFee types.Currency) (renter, host types.Currency)
RenewalCost calculates the cost to the host and renter for renewing a contract.
func SectorRoot ¶
func SectorRoot(sector *[SectorSize]byte) types.Hash256
SectorRoot computes the Merkle root of a sector.
func VerifyAppendSectorsProof ¶
func VerifyAppendSectorsProof(numSectors uint64, subtreeRoots []types.Hash256, appended []types.Hash256, oldRoot, newRoot types.Hash256) bool
VerifyAppendSectorsProof verifies a Merkle proof produced by BuildAppendProof.
func VerifyFreeSectorsProof ¶
func VerifyFreeSectorsProof(treeHashes, leafHashes []types.Hash256, freed []uint64, numSectors uint64, oldRoot types.Hash256, newRoot types.Hash256) bool
VerifyFreeSectorsProof verifies a Merkle proof produced by BuildFreeSectorsProof.
func VerifyLeafProof ¶
func VerifyLeafProof(proof []types.Hash256, leaf [64]byte, leafIndex uint64, root types.Hash256) bool
VerifyLeafProof verifies the Merkle proof for a given leaf within a sector.
func VerifySectorRootsProof ¶
func VerifySectorRootsProof(proof, sectorRoots []types.Hash256, numSectors, start, end uint64, root types.Hash256) bool
VerifySectorRootsProof verifies a Merkle proof produced by BuildSectorRootsProof.
func WriteRequest ¶
WriteRequest writes a request to the stream.
Types ¶
type Account ¶
An Account represents an ephemeral balance that can be funded via contract revision and spent to pay for RPCs.
func GenerateAccount ¶
func GenerateAccount() (types.PrivateKey, Account)
GenerateAccount generates a pair of private key and Account from a secure entropy source.
func (*Account) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (Account) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Account) Token ¶ added in v0.9.0
func (a *Account) Token(renterKey types.PrivateKey, hostKey types.PublicKey) AccountToken
Token returns a signed account token authorizing spending from the account on the host.
func (*Account) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type AccountDeposit ¶
type AccountDeposit struct { Account Account `json:"account"` Amount types.Currency `json:"amount"` }
An AccountDeposit represents a transfer into an account.
func (*AccountDeposit) DecodeFrom ¶
func (ad *AccountDeposit) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (AccountDeposit) EncodeTo ¶
func (ad AccountDeposit) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
type AccountToken ¶
type AccountToken struct { HostKey types.PublicKey `json:"hostKey"` Account Account `json:"account"` ValidUntil time.Time `json:"validUntil"` Signature types.Signature `json:"signature"` }
An AccountToken authorizes an account action.
func (*AccountToken) SigHash ¶
func (at *AccountToken) SigHash() types.Hash256
SigHash returns the hash of the account token used for signing.
type HostPrices ¶
type HostPrices struct { ContractPrice types.Currency `json:"contractPrice"` Collateral types.Currency `json:"collateral"` StoragePrice types.Currency `json:"storagePrice"` IngressPrice types.Currency `json:"ingressPrice"` EgressPrice types.Currency `json:"egressPrice"` FreeSectorPrice types.Currency `json:"freeSectorPrice"` TipHeight uint64 `json:"tipHeight"` ValidUntil time.Time `json:"validUntil"` // covers above fields Signature types.Signature `json:"signature"` }
HostPrices specify a time-bound set of parameters used to calculate the cost of various RPCs.
func (*HostPrices) DecodeFrom ¶
func (hp *HostPrices) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (HostPrices) EncodeTo ¶
func (hp HostPrices) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
func (HostPrices) RPCAppendSectorsCost ¶
func (hp HostPrices) RPCAppendSectorsCost(sectors, duration uint64) Usage
RPCAppendSectorsCost returns the cost of appending sectors to a contract. The duration parameter is the number of blocks until the contract's expiration height.
func (HostPrices) RPCFreeSectorsCost ¶
func (hp HostPrices) RPCFreeSectorsCost(sectors int) Usage
RPCFreeSectorsCost returns the cost of removing sectors from a contract.
func (HostPrices) RPCReadSectorCost ¶
func (hp HostPrices) RPCReadSectorCost(length uint64) Usage
RPCReadSectorCost returns the cost of reading a sector of the given length.
func (HostPrices) RPCSectorRootsCost ¶
func (hp HostPrices) RPCSectorRootsCost(length uint64) Usage
RPCSectorRootsCost returns the cost of fetching sector roots for the given length.
func (HostPrices) RPCVerifySectorCost ¶
func (hp HostPrices) RPCVerifySectorCost() Usage
RPCVerifySectorCost returns the cost of building a proof for the specified sector.
func (HostPrices) RPCWriteSectorCost ¶
func (hp HostPrices) RPCWriteSectorCost(sectorLength uint64) Usage
RPCWriteSectorCost returns the cost of executing the WriteSector RPC with the given sector length.
func (HostPrices) SigHash ¶
func (hp HostPrices) SigHash() types.Hash256
SigHash returns the hash of the host settings used for signing.
type HostSettings ¶
type HostSettings struct { ProtocolVersion [3]uint8 `json:"protocolVersion"` Release string `json:"release"` WalletAddress types.Address `json:"walletAddress"` AcceptingContracts bool `json:"acceptingContracts"` MaxCollateral types.Currency `json:"maxCollateral"` MaxContractDuration uint64 `json:"maxContractDuration"` RemainingStorage uint64 `json:"remainingStorage"` TotalStorage uint64 `json:"totalStorage"` Prices HostPrices `json:"prices"` }
HostSettings specify the settings of a host.
func (*HostSettings) DecodeFrom ¶
func (hs *HostSettings) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (HostSettings) EncodeTo ¶
func (hs HostSettings) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
type Object ¶
type Object interface {
// contains filtered or unexported methods
}
An Object can be sent or received via a Transport.
type RPCAccountBalanceRequest ¶
type RPCAccountBalanceRequest struct {
Account Account `json:"account"`
}
RPCAccountBalanceRequest implements Object.
type RPCAccountBalanceResponse ¶
RPCAccountBalanceResponse implements Object.
type RPCAppendSectorsRequest ¶
type RPCAppendSectorsRequest struct { Prices HostPrices `json:"prices"` Sectors []types.Hash256 `json:"sectors"` ContractID types.FileContractID `json:"contractID"` ChallengeSignature types.Signature `json:"challengeSignature"` }
RPCAppendSectorsRequest implements Object.
func (*RPCAppendSectorsRequest) ChallengeSigHash ¶
func (r *RPCAppendSectorsRequest) ChallengeSigHash(revisionNumber uint64) types.Hash256
ChallengeSigHash returns the hash of the challenge signature used for signing.
func (*RPCAppendSectorsRequest) ValidChallengeSignature ¶
func (r *RPCAppendSectorsRequest) ValidChallengeSignature(fc types.V2FileContract) bool
ValidChallengeSignature checks the challenge signature for validity.
type RPCAppendSectorsResponse ¶
type RPCAppendSectorsResponse struct { Accepted []bool `json:"accepted"` SubtreeRoots []types.Hash256 `json:"subtreeRoots"` NewMerkleRoot types.Hash256 `json:"newMerkleRoot"` }
RPCAppendSectorsResponse implements Object.
type RPCAppendSectorsSecondResponse ¶
type RPCAppendSectorsSecondResponse struct {
RenterSignature types.Signature `json:"renterSignature"`
}
RPCAppendSectorsSecondResponse implements Object.
type RPCAppendSectorsThirdResponse ¶
RPCAppendSectorsThirdResponse implements Object.
type RPCFormContractParams ¶
type RPCFormContractParams struct { RenterPublicKey types.PublicKey `json:"renterPublicKey"` RenterAddress types.Address `json:"renterAddress"` Allowance types.Currency `json:"allowance"` Collateral types.Currency `json:"collateral"` ProofHeight uint64 `json:"proofHeight"` }
RPCFormContractParams includes the contract details required to construct a contract.
type RPCFormContractRequest ¶
type RPCFormContractRequest struct { Prices HostPrices `json:"prices"` Contract RPCFormContractParams `json:"contract"` MinerFee types.Currency `json:"minerFee"` Basis types.ChainIndex `json:"basis"` RenterInputs []types.SiacoinElement `json:"renterInputs"` RenterParents []types.V2Transaction `json:"renterParents"` }
RPCFormContractRequest implements Object.
type RPCFormContractResponse ¶
type RPCFormContractResponse struct {
HostInputs []types.V2SiacoinInput `json:"hostInputs"`
}
RPCFormContractResponse implements Object.
type RPCFormContractSecondResponse ¶
type RPCFormContractSecondResponse struct { RenterContractSignature types.Signature `json:"renterContractSignature"` RenterSatisfiedPolicies []types.SatisfiedPolicy `json:"renterSatisfiedPolicies"` }
RPCFormContractSecondResponse implements Object.
type RPCFormContractThirdResponse ¶
type RPCFormContractThirdResponse struct { Basis types.ChainIndex `json:"basis"` TransactionSet []types.V2Transaction `json:"transactionSet"` }
RPCFormContractThirdResponse implements Object.
type RPCFreeSectorsRequest ¶
type RPCFreeSectorsRequest struct { ContractID types.FileContractID `json:"contractID"` Prices HostPrices `json:"prices"` Indices []uint64 `json:"indices"` // A ChallengeSignature proves the renter can modify the contract. ChallengeSignature types.Signature `json:"challengeSignature"` }
RPCFreeSectorsRequest implements Object.
func (*RPCFreeSectorsRequest) ChallengeSigHash ¶
func (r *RPCFreeSectorsRequest) ChallengeSigHash(revisionNumber uint64) types.Hash256
ChallengeSigHash returns the hash of the challenge signature used for signing.
func (*RPCFreeSectorsRequest) ValidChallengeSignature ¶
func (r *RPCFreeSectorsRequest) ValidChallengeSignature(fc types.V2FileContract) bool
ValidChallengeSignature checks the challenge signature for validity.
func (*RPCFreeSectorsRequest) Validate ¶
func (req *RPCFreeSectorsRequest) Validate(pk types.PublicKey, fc types.V2FileContract) error
Validate validates a modify sectors request. Signatures are not validated.
type RPCFreeSectorsResponse ¶
type RPCFreeSectorsResponse struct { OldSubtreeHashes []types.Hash256 `json:"oldSubtreeHashes"` OldLeafHashes []types.Hash256 `json:"oldLeafHashes"` NewMerkleRoot types.Hash256 `json:"newMerkleRoot"` }
RPCFreeSectorsResponse implements Object.
type RPCFreeSectorsSecondResponse ¶
type RPCFreeSectorsSecondResponse struct {
RenterSignature types.Signature `json:"renterSignature"`
}
RPCFreeSectorsSecondResponse implements Object.
type RPCFreeSectorsThirdResponse ¶
RPCFreeSectorsThirdResponse implements Object.
type RPCFundAccountsRequest ¶
type RPCFundAccountsRequest struct { ContractID types.FileContractID `json:"contractID"` Deposits []AccountDeposit `json:"deposits"` RenterSignature types.Signature `json:"renterSignature"` }
RPCFundAccountsRequest implements Object.
type RPCFundAccountsResponse ¶
type RPCFundAccountsResponse struct { Balances []types.Currency `json:"balances"` HostSignature types.Signature `json:"hostSignature"` }
RPCFundAccountsResponse implements Object.
type RPCLatestRevisionRequest ¶
type RPCLatestRevisionRequest struct {
ContractID types.FileContractID `json:"contractID"`
}
RPCLatestRevisionRequest implements Object.
type RPCLatestRevisionResponse ¶
type RPCLatestRevisionResponse struct { Contract types.V2FileContract `json:"contract"` Revisable bool `json:"revisable"` Renewed bool `json:"renewed"` }
RPCLatestRevisionResponse implements Object.
The `Revisable` field indicates whether the host will accept further revisions to the contract. A host will not accept revisions too close to the proof window or revisions on contracts that have already been resolved. The `Renewed` field indicates whether the contract was renewed. If the contract was renewed, the renter can use `FileContractID.V2RenewalID` to get the ID of the new contract.
type RPCReadSectorRequest ¶
type RPCReadSectorRequest struct { Prices HostPrices `json:"prices"` Token AccountToken `json:"token"` Root types.Hash256 `json:"root"` Offset uint64 `json:"offset"` Length uint64 `json:"length"` }
RPCReadSectorRequest implements Object.
type RPCReadSectorResponse ¶
type RPCReadSectorResponse struct { Proof []types.Hash256 `json:"proof"` DataLength uint64 `json:"dataLength"` }
RPCReadSectorResponse implements Object.
type RPCRefreshContractParams ¶
type RPCRefreshContractParams struct { ContractID types.FileContractID `json:"contractID"` Allowance types.Currency `json:"allowance"` Collateral types.Currency `json:"collateral"` }
RPCRefreshContractParams includes the contract details required to refresh a contract.
type RPCRefreshContractRequest ¶
type RPCRefreshContractRequest struct { Prices HostPrices `json:"prices"` Refresh RPCRefreshContractParams `json:"refresh"` MinerFee types.Currency `json:"minerFee"` Basis types.ChainIndex `json:"basis"` RenterInputs []types.SiacoinElement `json:"renterInputs"` RenterParents []types.V2Transaction `json:"renterParents"` ChallengeSignature types.Signature `json:"challengeSignature"` }
RPCRefreshContractRequest implements Object.
func (*RPCRefreshContractRequest) ChallengeSigHash ¶
func (r *RPCRefreshContractRequest) ChallengeSigHash(lastRevisionNumber uint64) types.Hash256
ChallengeSigHash returns the challenge sighash used for proving ownership of a contract for the renew RPC.
func (*RPCRefreshContractRequest) ValidChallengeSignature ¶
func (r *RPCRefreshContractRequest) ValidChallengeSignature(existing types.V2FileContract) bool
ValidChallengeSignature checks the challenge signature for validity.
type RPCRefreshContractResponse ¶
type RPCRefreshContractResponse struct {
HostInputs []types.V2SiacoinInput `json:"hostInputs"`
}
RPCRefreshContractResponse implements Object.
type RPCRefreshContractSecondResponse ¶
type RPCRefreshContractSecondResponse struct { RenterRenewalSignature types.Signature `json:"renterRenewalSignature"` RenterContractSignature types.Signature `json:"renterContractSignature"` RenterSatisfiedPolicies []types.SatisfiedPolicy `json:"renterSatisfiedPolicies"` }
RPCRefreshContractSecondResponse implements Object.
type RPCRefreshContractThirdResponse ¶
type RPCRefreshContractThirdResponse struct { Basis types.ChainIndex `json:"basis"` TransactionSet []types.V2Transaction `json:"transactionSet"` }
RPCRefreshContractThirdResponse implements Object.
type RPCRenewContractParams ¶
type RPCRenewContractParams struct { ContractID types.FileContractID `json:"contractID"` Allowance types.Currency `json:"allowance"` Collateral types.Currency `json:"collateral"` ProofHeight uint64 `json:"proofHeight"` }
RPCRenewContractParams includes the contract details required to create a renewal.
type RPCRenewContractRequest ¶
type RPCRenewContractRequest struct { Prices HostPrices `json:"prices"` Renewal RPCRenewContractParams `json:"renewal"` MinerFee types.Currency `json:"minerFee"` Basis types.ChainIndex `json:"basis"` RenterInputs []types.SiacoinElement `json:"renterInputs"` RenterParents []types.V2Transaction `json:"renterParents"` ChallengeSignature types.Signature `json:"challengeSignature"` }
RPCRenewContractRequest implements Object.
func (*RPCRenewContractRequest) ChallengeSigHash ¶
func (r *RPCRenewContractRequest) ChallengeSigHash(lastRevisionNumber uint64) types.Hash256
ChallengeSigHash returns the challenge sighash used for proving ownership of a contract for the renew RPC.
func (*RPCRenewContractRequest) ValidChallengeSignature ¶
func (r *RPCRenewContractRequest) ValidChallengeSignature(existing types.V2FileContract) bool
ValidChallengeSignature checks the challenge signature for validity.
func (*RPCRenewContractRequest) Validate ¶
func (req *RPCRenewContractRequest) Validate(pk types.PublicKey, tip types.ChainIndex, existingSize uint64, existingProofHeight uint64, maxCollateral types.Currency, maxDuration uint64) error
Validate validates a renew contract request. Prices are not validated
type RPCRenewContractResponse ¶
type RPCRenewContractResponse struct {
HostInputs []types.V2SiacoinInput `json:"hostInputs"`
}
RPCRenewContractResponse implements Object.
type RPCRenewContractSecondResponse ¶
type RPCRenewContractSecondResponse struct { RenterRenewalSignature types.Signature `json:"renterRenewalSignature"` RenterContractSignature types.Signature `json:"renterContractSignature"` RenterSatisfiedPolicies []types.SatisfiedPolicy `json:"renterSatisfiedPolicies"` }
RPCRenewContractSecondResponse implements Object.
type RPCRenewContractThirdResponse ¶
type RPCRenewContractThirdResponse struct { Basis types.ChainIndex `json:"basis"` TransactionSet []types.V2Transaction `json:"transactionSet"` }
RPCRenewContractThirdResponse implements Object.
type RPCSectorRootsRequest ¶
type RPCSectorRootsRequest struct { Prices HostPrices `json:"prices"` ContractID types.FileContractID `json:"contractID"` RenterSignature types.Signature `json:"renterSignature"` Offset uint64 `json:"offset"` Length uint64 `json:"length"` }
RPCSectorRootsRequest implements Object.
func (*RPCSectorRootsRequest) Validate ¶
func (req *RPCSectorRootsRequest) Validate(pk types.PublicKey, fc types.V2FileContract) error
Validate validates a sector roots request. Signatures are not validated.
type RPCSectorRootsResponse ¶
type RPCSectorRootsResponse struct { Proof []types.Hash256 `json:"proof"` Roots []types.Hash256 `json:"roots"` HostSignature types.Signature `json:"hostSignature"` }
RPCSectorRootsResponse implements Object.
type RPCSettingsResponse ¶
type RPCSettingsResponse struct {
Settings HostSettings `json:"settings"`
}
RPCSettingsResponse implements Object.
type RPCVerifySectorRequest ¶
type RPCVerifySectorRequest struct { Prices HostPrices `json:"prices"` Token AccountToken `json:"token"` Root types.Hash256 `json:"root"` LeafIndex uint64 `json:"leafIndex"` }
RPCVerifySectorRequest implements Object.
type RPCVerifySectorResponse ¶
type RPCVerifySectorResponse struct { Proof []types.Hash256 `json:"proof"` Leaf [64]byte `json:"leaf"` }
RPCVerifySectorResponse implements Object.
type RPCWriteSectorRequest ¶
type RPCWriteSectorRequest struct { Prices HostPrices `json:"prices"` Token AccountToken `json:"token"` DataLength uint64 `json:"dataLength"` // extended to SectorSize by host }
RPCWriteSectorRequest implements Object.
type RPCWriteSectorResponse ¶
RPCWriteSectorResponse implements Object.
type RangeProofVerifier ¶
type RangeProofVerifier = rhp2.RangeProofVerifier
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 Usage ¶
type Usage struct { RPC types.Currency `json:"rpc"` Storage types.Currency `json:"storage"` Egress types.Currency `json:"egress"` Ingress types.Currency `json:"ingress"` AccountFunding types.Currency `json:"accountFunding"` RiskedCollateral types.Currency `json:"collateral"` }
Usage contains the cost breakdown and collateral of executing an RPC.
func NewContract ¶
func NewContract(p HostPrices, cp RPCFormContractParams, hostKey types.PublicKey, hostAddress types.Address) (types.V2FileContract, Usage)
NewContract creates a new file contract with the given settings.
func RefreshContract ¶
func RefreshContract(fc types.V2FileContract, prices HostPrices, rp RPCRefreshContractParams) (types.V2FileContractRenewal, Usage)
RefreshContract creates a contract renewal for the refresh RPC.
func RenewContract ¶
func RenewContract(fc types.V2FileContract, prices HostPrices, rp RPCRenewContractParams) (types.V2FileContractRenewal, Usage)
RenewContract creates a contract renewal for the renew RPC
func ReviseForAppendSectors ¶
func ReviseForAppendSectors(fc types.V2FileContract, prices HostPrices, root types.Hash256, appended uint64) (types.V2FileContract, Usage, error)
ReviseForAppendSectors creates a contract revision for the append sectors RPC
func ReviseForFreeSectors ¶
func ReviseForFreeSectors(fc types.V2FileContract, prices HostPrices, newRoot types.Hash256, deletions int) (types.V2FileContract, Usage, error)
ReviseForFreeSectors creates a contract revision for the free sectors RPC
func ReviseForFundAccounts ¶
func ReviseForFundAccounts(fc types.V2FileContract, amount types.Currency) (types.V2FileContract, Usage, error)
ReviseForFundAccounts creates a contract revision for the fund accounts RPC
func ReviseForSectorRoots ¶
func ReviseForSectorRoots(fc types.V2FileContract, prices HostPrices, numRoots uint64) (types.V2FileContract, Usage, error)
ReviseForSectorRoots creates a contract revision for the sector roots RPC
func (Usage) HostRiskedCollateral ¶
HostRiskedCollateral returns the amount of collateral the host must risk
func (Usage) RenterCost ¶
RenterCost returns the total cost of executing the RPC.