Documentation
¶
Overview ¶
Package rhp implements the Sia renter-host protocol, version 2.
Index ¶
- Constants
- Variables
- func BuildDiffProof(actions []RPCWriteAction, sectorRoots []types.Hash256) (treeHashes, leafHashes []types.Hash256)
- func BuildProof(sector *[SectorSize]byte, start, end uint64, ...) []types.Hash256
- func BuildSectorRangeProof(sectorRoots []types.Hash256, start, end uint64) []types.Hash256
- func CalculateHostPayouts(fc types.FileContract, newCollateral types.Currency, settings HostSettings, ...) (types.Currency, types.Currency, types.Currency, types.Currency)
- func ContractFormationCollateral(period uint64, expectedStorage uint64, host HostSettings) types.Currency
- func ContractFormationCost(cs consensus.State, fc types.FileContract, contractFee types.Currency) types.Currency
- func ContractRenewalCollateral(fc types.FileContract, expectedNewStorage uint64, host HostSettings, ...) types.Currency
- func ContractRenewalCost(cs consensus.State, fc types.FileContract, ...) types.Currency
- func ConvertProofOrdering(proof []types.Hash256, index uint64) []types.Hash256
- func DiffProofSize(actions []RPCWriteAction, numLeaves uint64) (numHashes uint64)
- func MetaRoot(roots []types.Hash256) types.Hash256
- func PrepareContractFormation(renterPubKey types.PublicKey, hostKey types.PublicKey, ...) types.FileContract
- func PrepareContractRenewal(currentRevision types.FileContractRevision, renterAddress types.Address, ...) (types.FileContract, types.Currency)
- func ProofSize(n, i uint64) uint64
- 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 SectorRoot(sector *[SectorSize]byte) types.Hash256
- func VerifyAppendProof(numLeaves uint64, treeHashes []types.Hash256, ...) bool
- func VerifyDiffProof(actions []RPCWriteAction, numLeaves uint64, ...) bool
- func VerifySectorRangeProof(proof []types.Hash256, rangeRoots []types.Hash256, start, end, numRoots uint64, ...) bool
- type Challenge
- type ContractRevision
- type HostSettings
- func (hs HostSettings) MarshalJSON() ([]byte, error)
- func (hs HostSettings) RPCReadCost(sections []RPCReadRequestSection, proof bool) (RPCCost, error)
- func (hs HostSettings) RPCSectorRootsCost(rootOffset, numRoots uint64) RPCCost
- func (hs HostSettings) RPCWriteCost(actions []RPCWriteAction, oldSectors, remainingDuration uint64, proof bool) (RPCCost, error)
- func (hs HostSettings) SiamuxAddr() string
- type ProtocolObject
- type RPCCost
- type RPCError
- type RPCFormContractAdditions
- type RPCFormContractRequest
- type RPCFormContractSignatures
- type RPCLockRequest
- type RPCLockResponse
- type RPCReadRequest
- type RPCReadRequestSection
- type RPCReadResponse
- type RPCRenewAndClearContractRequest
- type RPCRenewAndClearContractSignatures
- type RPCSectorRootsRequest
- type RPCSectorRootsResponse
- type RPCSettingsResponse
- type RPCWriteAction
- type RPCWriteMerkleProof
- type RPCWriteRequest
- type RPCWriteResponse
- type RangeProofVerifier
- type ResponseReader
- type Transport
- func (t *Transport) BytesRead() uint64
- func (t *Transport) BytesWritten() uint64
- func (t *Transport) Call(rpcID types.Specifier, req, resp ProtocolObject) error
- func (t *Transport) Close() (err error)
- func (t *Transport) ForceClose() (err error)
- func (t *Transport) HostKey() types.PublicKey
- func (t *Transport) IsClosed() bool
- func (t *Transport) PrematureCloseErr() error
- func (t *Transport) RawResponse(maxLen uint64) (*ResponseReader, error)
- func (t *Transport) ReadID() (rpcID types.Specifier, err error)
- func (t *Transport) ReadRequest(req ProtocolObject, maxLen uint64) (err error)
- func (t *Transport) ReadResponse(resp ProtocolObject, maxLen uint64) (err error)
- func (t *Transport) SetChallenge(c Challenge)
- func (t *Transport) SetDeadline(deadline time.Time)
- func (t *Transport) SetReadDeadline(deadline time.Time)
- func (t *Transport) SetWriteDeadline(deadline time.Time)
- func (t *Transport) SignChallenge(priv types.PrivateKey) types.Signature
- func (t *Transport) VerifyChallenge(sig types.Signature, pubkey types.PublicKey) (Challenge, bool)
- func (t *Transport) WriteRequest(rpcID types.Specifier, req ProtocolObject) error
- func (t *Transport) WriteResponse(resp ProtocolObject) (e error)
- func (t *Transport) WriteResponseErr(err error) (e error)
Constants ¶
const ( // LeafSize is the size of one leaf in bytes. LeafSize = 64 // LeavesPerSector is the number of leaves in one sector. LeavesPerSector = SectorSize / LeafSize )
const SectorSize = 1 << 22 // 4 MiB
SectorSize is the size of one sector in bytes.
Variables ¶
var ( RPCFormContractID = types.NewSpecifier("LoopFormContract") RPCLockID = types.NewSpecifier("LoopLock") RPCReadID = types.NewSpecifier("LoopRead") RPCRenewContractID = types.NewSpecifier("LoopRenew") RPCRenewClearContractID = types.NewSpecifier("LoopRenewClear") RPCSectorRootsID = types.NewSpecifier("LoopSectorRoots") RPCSettingsID = types.NewSpecifier("LoopSettings") RPCUnlockID = types.NewSpecifier("LoopUnlock") RPCWriteID = types.NewSpecifier("LoopWrite") )
RPC IDs
var ( RPCWriteActionAppend = types.NewSpecifier("Append") RPCWriteActionTrim = types.NewSpecifier("Trim") RPCWriteActionSwap = types.NewSpecifier("Swap") RPCWriteActionUpdate = types.NewSpecifier("Update") RPCReadStop = types.NewSpecifier("ReadStop") )
Read/Write actions
var ( // ErrOffsetOutOfBounds is returned when the offset exceeds and length // exceed the sector size. ErrOffsetOutOfBounds = errors.New("update section is out of bounds") // ErrInvalidSectorLength is returned when a sector is not the correct // length. ErrInvalidSectorLength = errors.New("length of sector data must be exactly 4MiB") // ErrSwapOutOfBounds is returned when one of the swap indices exceeds the // total number of sectors ErrSwapOutOfBounds = errors.New("swap index is out of bounds") // ErrTrimOutOfBounds is returned when a trim operation exceeds the total // number of sectors ErrTrimOutOfBounds = errors.New("trim size exceeds number of sectors") // ErrUpdateOutOfBounds is returned when the update index exceeds the total // number of sectors ErrUpdateOutOfBounds = errors.New("update index is out of bounds") // ErrUpdateProofSize is returned when a proof is requested for an update // operation that is not a multiple of 64 bytes. ErrUpdateProofSize = errors.New("update section is not a multiple of the segment size") )
RPC read/write errors
var ( // ErrRenterClosed is returned by (*Transport).ReadID when the renter sends the // Transport termination signal. ErrRenterClosed = errors.New("renter has terminated Transport") )
Functions ¶
func BuildDiffProof ¶
func BuildDiffProof(actions []RPCWriteAction, sectorRoots []types.Hash256) (treeHashes, leafHashes []types.Hash256)
BuildDiffProof constructs a diff proof for the specified actions. ActionUpdate is not supported.
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 CalculateHostPayouts ¶
func CalculateHostPayouts(fc types.FileContract, newCollateral types.Currency, settings HostSettings, endHeight uint64) (types.Currency, types.Currency, types.Currency, types.Currency)
CalculateHostPayouts calculates the contract payouts for the host.
func ContractFormationCollateral ¶
func ContractFormationCollateral(period uint64, expectedStorage uint64, host HostSettings) types.Currency
ContractFormationCollateral returns the amount of collateral we add when forming a contract where expectedStorage is the amount of storage we expect to upload to the contract.
func ContractFormationCost ¶
func ContractFormationCost(cs consensus.State, fc types.FileContract, contractFee types.Currency) types.Currency
ContractFormationCost returns the cost of forming a contract.
func ContractRenewalCollateral ¶
func ContractRenewalCollateral(fc types.FileContract, expectedNewStorage uint64, host HostSettings, blockHeight, endHeight uint64) types.Currency
ContractRenewalCollateral returns the amount of collateral we add on top of the baseCollateral when renewing a contract. It takes into account the host's max collateral setting and ensures the total collateral does not exceed it. expectedNewStorage is the amount of storage we expect to be uploaded additionally to the amount of storage already in the contract.
func ContractRenewalCost ¶
func ContractRenewalCost(cs consensus.State, fc types.FileContract, contractFee, 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 ConvertProofOrdering ¶
ConvertProofOrdering converts "left-to-right" proofs into the "leaf-to-root" ordering used in consensus storage proofs.
func DiffProofSize ¶
func DiffProofSize(actions []RPCWriteAction, numLeaves uint64) (numHashes uint64)
DiffProofSize returns the size of a Merkle diff proof for the specified actions within a tree containing numLeaves leaves.
func PrepareContractFormation ¶
func PrepareContractFormation(renterPubKey types.PublicKey, hostKey types.PublicKey, renterPayout, hostCollateral types.Currency, endHeight uint64, host HostSettings, refundAddr types.Address) types.FileContract
PrepareContractFormation constructs a contract formation transaction.
func PrepareContractRenewal ¶
func PrepareContractRenewal(currentRevision types.FileContractRevision, renterAddress types.Address, renterPayout, newCollateral types.Currency, host HostSettings, endHeight uint64) (types.FileContract, types.Currency)
PrepareContractRenewal constructs a contract renewal transaction.
func ProofSize ¶
ProofSize returns the size of a Merkle proof for the leaf i within a tree containing n leaves.
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 SectorRoot ¶
func SectorRoot(sector *[SectorSize]byte) types.Hash256
SectorRoot computes the Merkle root of a sector.
func VerifyAppendProof ¶
func VerifyAppendProof(numLeaves uint64, treeHashes []types.Hash256, sectorRoot, oldRoot, newRoot types.Hash256) bool
VerifyAppendProof verifies a proof produced by BuildAppendProof.
func VerifyDiffProof ¶
func VerifyDiffProof(actions []RPCWriteAction, numLeaves uint64, treeHashes, leafHashes []types.Hash256, oldRoot, newRoot types.Hash256, appendRoots []types.Hash256) bool
VerifyDiffProof verifies a proof produced by BuildDiffProof. ActionUpdate is not supported. If appendRoots is non-nil, it is assumed to contain the precomputed SectorRoots of all Append actions.
Types ¶
type Challenge ¶ added in v0.4.0
type Challenge [16]byte
A Challenge is a random 128-bit value used to authenticate RPCs.
func (*Challenge) DecodeFrom ¶ added in v0.4.0
DecodeFrom implements ProtocolObject.
type ContractRevision ¶
type ContractRevision struct { Revision types.FileContractRevision Signatures [2]types.TransactionSignature }
A ContractRevision pairs a file contract with its signatures.
func (ContractRevision) EndHeight ¶
func (c ContractRevision) EndHeight() uint64
EndHeight returns the height at which the host is no longer obligated to store contract data.
func (ContractRevision) HostKey ¶
func (c ContractRevision) HostKey() (pk types.PublicKey)
HostKey returns the public key of the host.
func (ContractRevision) ID ¶
func (c ContractRevision) ID() types.FileContractID
ID returns the ID of the original FileContract.
func (ContractRevision) NumSectors ¶
func (c ContractRevision) NumSectors() uint64
NumSectors returns the number of sectors covered by the contract.
func (ContractRevision) RenterFunds ¶
func (c ContractRevision) RenterFunds() types.Currency
RenterFunds returns the funds remaining in the contract's Renter payout.
type HostSettings ¶
type HostSettings struct { AcceptingContracts bool `json:"acceptingcontracts"` MaxDownloadBatchSize uint64 `json:"maxdownloadbatchsize"` MaxDuration uint64 `json:"maxduration"` MaxReviseBatchSize uint64 `json:"maxrevisebatchsize"` NetAddress string `json:"netaddress"` RemainingStorage uint64 `json:"remainingstorage"` SectorSize uint64 `json:"sectorsize"` TotalStorage uint64 `json:"totalstorage"` Address types.Address `json:"unlockhash"` WindowSize uint64 `json:"windowsize"` Collateral types.Currency `json:"collateral"` MaxCollateral types.Currency `json:"maxcollateral"` BaseRPCPrice types.Currency `json:"baserpcprice"` ContractPrice types.Currency `json:"contractprice"` DownloadBandwidthPrice types.Currency `json:"downloadbandwidthprice"` SectorAccessPrice types.Currency `json:"sectoraccessprice"` StoragePrice types.Currency `json:"storageprice"` UploadBandwidthPrice types.Currency `json:"uploadbandwidthprice"` EphemeralAccountExpiry time.Duration `json:"ephemeralaccountexpiry"` MaxEphemeralAccountBalance types.Currency `json:"maxephemeralaccountbalance"` RevisionNumber uint64 `json:"revisionnumber"` Version string `json:"version"` Release string `json:"release"` SiaMuxPort string `json:"siamuxport"` }
HostSettings are the settings and prices used when interacting with a host.
func (HostSettings) MarshalJSON ¶ added in v0.1.10
func (hs HostSettings) MarshalJSON() ([]byte, error)
MarshalJSON encodes the HostSettings as JSON. The Address field is overridden for compatibility with siad renters.
func (HostSettings) RPCReadCost ¶ added in v0.1.12
func (hs HostSettings) RPCReadCost(sections []RPCReadRequestSection, proof bool) (RPCCost, error)
RPCReadCost returns the cost of a Read RPC.
func (HostSettings) RPCSectorRootsCost ¶ added in v0.1.12
func (hs HostSettings) RPCSectorRootsCost(rootOffset, numRoots uint64) RPCCost
RPCSectorRootsCost returns the cost of a SectorRoots RPC.
func (HostSettings) RPCWriteCost ¶ added in v0.1.12
func (hs HostSettings) RPCWriteCost(actions []RPCWriteAction, oldSectors, remainingDuration uint64, proof bool) (RPCCost, error)
RPCWriteCost returns the cost of a Write RPC.
func (HostSettings) SiamuxAddr ¶
func (hs HostSettings) SiamuxAddr() string
SiamuxAddr is a helper which returns an address that can be used to connect to the host's siamux.
type ProtocolObject ¶
type ProtocolObject interface { types.EncoderTo types.DecoderFrom }
A ProtocolObject is an object that can be serialized for transport in the renter-host protocol.
type RPCCost ¶ added in v0.1.12
type RPCCost struct { Base types.Currency Storage types.Currency Ingress types.Currency Egress types.Currency Collateral types.Currency }
RPCCost represents the cost of an RPC based on a hosts settings.
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 RPCFormContractAdditions ¶
type RPCFormContractAdditions struct { Parents []types.Transaction Inputs []types.SiacoinInput Outputs []types.SiacoinOutput }
RPCFormContractAdditions contains the parent transaction, inputs, and outputs added by the host when negotiating a file contract.
func (*RPCFormContractAdditions) DecodeFrom ¶
func (r *RPCFormContractAdditions) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFormContractAdditions) EncodeTo ¶
func (r *RPCFormContractAdditions) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCFormContractRequest ¶
type RPCFormContractRequest struct { Transactions []types.Transaction RenterKey types.UnlockKey }
RPCFormContractRequest contains the request parameters for the FormContract and RenewContract RPCs.
func (*RPCFormContractRequest) DecodeFrom ¶
func (r *RPCFormContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFormContractRequest) EncodeTo ¶
func (r *RPCFormContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCFormContractSignatures ¶
type RPCFormContractSignatures struct { ContractSignatures []types.TransactionSignature RevisionSignature types.TransactionSignature }
RPCFormContractSignatures contains the signatures for a contract transaction and initial revision. These signatures are sent by both the renter and host during contract formation and renewal.
func (*RPCFormContractSignatures) DecodeFrom ¶
func (r *RPCFormContractSignatures) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCFormContractSignatures) EncodeTo ¶
func (r *RPCFormContractSignatures) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCLockRequest ¶
type RPCLockRequest struct { ContractID types.FileContractID Signature types.Signature Timeout uint64 }
RPCLockRequest contains the request parameters for the Lock RPC.
func (*RPCLockRequest) DecodeFrom ¶
func (r *RPCLockRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCLockRequest) EncodeTo ¶
func (r *RPCLockRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCLockResponse ¶
type RPCLockResponse struct { Acquired bool NewChallenge Challenge Revision types.FileContractRevision Signatures []types.TransactionSignature }
RPCLockResponse contains the response data for the Lock RPC.
func (*RPCLockResponse) DecodeFrom ¶
func (r *RPCLockResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCLockResponse) EncodeTo ¶
func (r *RPCLockResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCReadRequest ¶
type RPCReadRequest struct { Sections []RPCReadRequestSection MerkleProof bool RevisionNumber uint64 ValidProofValues []types.Currency MissedProofValues []types.Currency Signature types.Signature }
RPCReadRequest contains the request parameters for the Read RPC.
func (*RPCReadRequest) DecodeFrom ¶
func (r *RPCReadRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCReadRequest) EncodeTo ¶
func (r *RPCReadRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
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 ProtocolObject.
func (*RPCReadResponse) EncodeTo ¶
func (r *RPCReadResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCRenewAndClearContractRequest ¶
type RPCRenewAndClearContractRequest struct { Transactions []types.Transaction RenterKey types.UnlockKey FinalValidProofValues []types.Currency FinalMissedProofValues []types.Currency }
RPCRenewAndClearContractRequest contains the request parameters for the RenewAndClearContract RPC.
func (*RPCRenewAndClearContractRequest) DecodeFrom ¶
func (r *RPCRenewAndClearContractRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCRenewAndClearContractRequest) EncodeTo ¶
func (r *RPCRenewAndClearContractRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCRenewAndClearContractSignatures ¶
type RPCRenewAndClearContractSignatures struct { ContractSignatures []types.TransactionSignature RevisionSignature types.TransactionSignature FinalRevisionSignature types.Signature }
RPCRenewAndClearContractSignatures contains the signatures for a contract transaction, initial revision, and final revision of the contract being renewed. These signatures are sent by both the renter and host during the RenewAndClear RPC.
func (*RPCRenewAndClearContractSignatures) DecodeFrom ¶
func (r *RPCRenewAndClearContractSignatures) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCRenewAndClearContractSignatures) EncodeTo ¶
func (r *RPCRenewAndClearContractSignatures) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCSectorRootsRequest ¶
type RPCSectorRootsRequest struct { RootOffset uint64 NumRoots uint64 RevisionNumber uint64 ValidProofValues []types.Currency MissedProofValues []types.Currency Signature types.Signature }
RPCSectorRootsRequest contains the request parameters for the SectorRoots RPC.
func (*RPCSectorRootsRequest) DecodeFrom ¶
func (r *RPCSectorRootsRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCSectorRootsRequest) EncodeTo ¶
func (r *RPCSectorRootsRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
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 ProtocolObject.
func (*RPCSectorRootsResponse) EncodeTo ¶
func (r *RPCSectorRootsResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCSettingsResponse ¶
type RPCSettingsResponse struct {
Settings []byte // JSON-encoded hostdb.HostSettings
}
RPCSettingsResponse contains the response data for the SettingsResponse RPC.
func (*RPCSettingsResponse) DecodeFrom ¶
func (r *RPCSettingsResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCSettingsResponse) EncodeTo ¶
func (r *RPCSettingsResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCWriteAction ¶
RPCWriteAction is a generic Write action. The meaning of each field depends on the Type of the action.
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 ProtocolObject.
func (*RPCWriteMerkleProof) EncodeTo ¶
func (r *RPCWriteMerkleProof) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCWriteRequest ¶
type RPCWriteRequest struct { Actions []RPCWriteAction MerkleProof bool RevisionNumber uint64 ValidProofValues []types.Currency MissedProofValues []types.Currency }
RPCWriteRequest contains the request parameters for the Write RPC.
func (*RPCWriteRequest) DecodeFrom ¶
func (r *RPCWriteRequest) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCWriteRequest) EncodeTo ¶
func (r *RPCWriteRequest) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
type RPCWriteResponse ¶
RPCWriteResponse contains the response data for the Write RPC.
func (*RPCWriteResponse) DecodeFrom ¶
func (r *RPCWriteResponse) DecodeFrom(d *types.Decoder)
DecodeFrom implements ProtocolObject.
func (*RPCWriteResponse) EncodeTo ¶
func (r *RPCWriteResponse) EncodeTo(e *types.Encoder)
EncodeTo implements ProtocolObject.
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 ResponseReader ¶
type ResponseReader struct {
// contains filtered or unexported fields
}
A ResponseReader contains an unencrypted, unauthenticated RPC response message.
func (*ResponseReader) Read ¶
func (rr *ResponseReader) Read(p []byte) (int, error)
Read implements io.Reader.
func (*ResponseReader) VerifyTag ¶
func (rr *ResponseReader) VerifyTag() error
VerifyTag verifies the authentication tag appended to the message. VerifyTag must be called after Read returns io.EOF, and the message must be discarded if VerifyTag returns a non-nil error.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
A Transport facilitates the exchange of RPCs via the renter-host protocol, version 2.
func NewHostTransport ¶
NewHostTransport conducts the hosts's half of the renter-host protocol handshake, returning a Transport that can be used to handle RPC requests.
func NewRenterTransport ¶
NewRenterTransport conducts the renter's half of the renter-host protocol handshake, returning a Transport that can be used to make RPC requests.
func (*Transport) BytesRead ¶
BytesRead returns the number of bytes read from the underlying connection.
func (*Transport) BytesWritten ¶
BytesWritten returns the number of bytes written to the underlying connection.
func (*Transport) Call ¶
func (t *Transport) Call(rpcID types.Specifier, req, resp ProtocolObject) error
Call is a helper method that writes a request and then reads a response.
func (*Transport) ForceClose ¶ added in v0.1.9
ForceClose calls Close on the transport's underlying connection.
func (*Transport) IsClosed ¶
IsClosed returns whether the Transport is closed. Check PrematureCloseErr to determine whether the Transport was closed gracefully.
func (*Transport) PrematureCloseErr ¶
PrematureCloseErr returns the error that resulted in the Transport being closed prematurely.
func (*Transport) RawResponse ¶
func (t *Transport) RawResponse(maxLen uint64) (*ResponseReader, error)
RawResponse returns a stream containing the (unencrypted, unauthenticated) content of the next message. The Reader must be fully consumed by the caller, after which the caller should call VerifyTag to authenticate the message. If the response was an RPCError, it is authenticated and returned immediately.
func (*Transport) ReadID ¶
ReadID reads an RPC request ID. If the renter sends the Transport termination signal, ReadID returns ErrRenterClosed.
func (*Transport) ReadRequest ¶
func (t *Transport) ReadRequest(req ProtocolObject, maxLen uint64) (err error)
ReadRequest reads an RPC request using the new loop protocol.
func (*Transport) ReadResponse ¶
func (t *Transport) ReadResponse(resp ProtocolObject, maxLen uint64) (err error)
ReadResponse reads an RPC response. If the response is an error, it is returned directly.
func (*Transport) SetChallenge ¶
SetChallenge sets the current Transport challenge.
func (*Transport) SetDeadline ¶ added in v0.1.7
SetDeadline sets the read and write deadline on the underlying connection.
func (*Transport) SetReadDeadline ¶ added in v0.1.7
SetReadDeadline sets the deadline for future read calls on the underlying connection.
func (*Transport) SetWriteDeadline ¶ added in v0.1.7
SetWriteDeadline sets the deadline for future write calls on the underlying connection.
func (*Transport) SignChallenge ¶
func (t *Transport) SignChallenge(priv types.PrivateKey) types.Signature
SignChallenge signs the current Transport challenge.
func (*Transport) VerifyChallenge ¶
VerifyChallenge verifies a challenge signature and returns a new challenge.
func (*Transport) WriteRequest ¶
func (t *Transport) WriteRequest(rpcID types.Specifier, req ProtocolObject) error
WriteRequest sends an encrypted RPC request, comprising an RPC ID and a request object.
func (*Transport) WriteResponse ¶
func (t *Transport) WriteResponse(resp ProtocolObject) (e error)
WriteResponse writes an RPC response object.
func (*Transport) 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.