rhp

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearingRevision

func ClearingRevision(revision types.FileContractRevision, outputValues []types.Currency) (types.FileContractRevision, error)

ClearingRevision returns a revision that locks a contract and sets the missed proof outputs to the valid proof outputs.

func HashRevision

func HashRevision(rev types.FileContractRevision) types.Hash256

HashRevision returns the hash of rev.

func InitialRevision

func InitialRevision(formationTxn *types.Transaction, hostPubKey, renterPubKey types.UnlockKey) types.FileContractRevision

InitialRevision returns the first revision of a file contract formation transaction.

func Revise

func Revise(revision types.FileContractRevision, revisionNumber uint64, validOutputs, missedOutputs []types.Currency) (types.FileContractRevision, error)

Revise updates the contract revision with the provided values.

func ValidateClearingRevision

func ValidateClearingRevision(current, final types.FileContractRevision, finalPayment types.Currency) (types.Currency, error)

ValidateClearingRevision verifies that the revision locks the current contract by setting its revision number to the maximum value and the valid and missed proof outputs are the same.

func ValidatePaymentRevision

func ValidatePaymentRevision(current, revision types.FileContractRevision, payment 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.FileContractRevision, storage, collateral types.Currency) (burn types.Currency, _ error)

ValidateProgramRevision verifies that a contract program revision is valid and only the missed host value and burn value are modified by the expected burn amount. All other usage will have been paid for by the RPC budget.

func ValidateRevision

func ValidateRevision(current, revision types.FileContractRevision, payment, collateral types.Currency) (transfer, burn types.Currency, err error)

ValidateRevision verifies that a new revision is valid given the current revision. Only the revision number and proof output values are allowed to change

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

An Conn wraps a net.Conn to track the amount of data read and written and limit bandwidth usage.

func NewConn

func NewConn(c net.Conn, m DataMonitor, rl, wl *rate.Limiter) *Conn

NewConn initializes a new RPC conn wrapper.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read implements io.Reader

func (*Conn) Usage

func (c *Conn) Usage() (read, written uint64)

Usage returns the amount of data read and written by the connection.

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Write implements io.Writer

type DataMonitor

type DataMonitor interface {
	ReadBytes(n int)
	WriteBytes(n int)
}

A DataMonitor records the amount of data read and written across all connections.

type DataRecorder

type DataRecorder struct {
	// contains filtered or unexported fields
}

A DataRecorder records the amount of data read and written across connections.

func NewDataRecorder

func NewDataRecorder(store DataRecorderStore, log *zap.Logger) *DataRecorder

NewDataRecorder initializes a new DataRecorder

func (*DataRecorder) Close

func (dr *DataRecorder) Close() error

Close persists any remaining usage and returns nil

func (*DataRecorder) ReadBytes

func (dr *DataRecorder) ReadBytes(n int)

ReadBytes increments the number of bytes read by n.

func (*DataRecorder) Usage

func (dr *DataRecorder) Usage() (read, written uint64)

Usage returns the number of bytes read and written

func (*DataRecorder) WriteBytes

func (dr *DataRecorder) WriteBytes(n int)

WriteBytes increments the number of bytes written by n.

type DataRecorderStore

type DataRecorderStore interface {
	IncrementDataUsage(ingress, egress uint64) error
}

A DataRecorderStore persists data usage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL