Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyProgram is returned if the program doesn't contain any instructions. ErrEmptyProgram = errors.New("can't execute program without instructions") // ErrInterrupted indicates that the program was interrupted during // execution and couldn't finish. ErrInterrupted = errors.New("execution of program was interrupted") )
Functions ¶
func NewAppendInstruction ¶ added in v1.4.3
func NewAppendInstruction(dataOffset uint64, merkleProof bool) modules.Instruction
NewAppendInstruction creates a modules.Instruction from arguments.
func NewDropSectorsInstruction ¶ added in v1.4.4
func NewDropSectorsInstruction(numSectorsOffset uint64, merkleProof bool) modules.Instruction
NewDropSectorsInstruction creates a modules.Instruction from arguments.
Types ¶
type Host ¶
type Host interface { BlockHeight() types.BlockHeight HasSector(crypto.Hash) bool ReadSector(sectorRoot crypto.Hash) ([]byte, error) }
Host defines the minimal interface a Host needs to implement to be used by the mdm.
type MDM ¶
type MDM struct {
// contains filtered or unexported fields
}
MDM (Merklized Data Machine) is a virtual machine that executes instructions on the data in a Sia file contract. The file contract tracks the size and Merkle root of the underlying data, which the MDM will update when running instructions that modify the file contract data. Each instruction can optionally produce a cryptographic proof that the instruction was executed honestly. Every instruction has an execution cost, and instructions are batched into atomic sets called 'programs' that are either entirely applied or are not applied at all.
func (*MDM) ExecuteProgram ¶
func (mdm *MDM) ExecuteProgram(ctx context.Context, pt *modules.RPCPriceTable, p modules.Program, budget *modules.RPCBudget, collateralBudget types.Currency, sos StorageObligationSnapshot, programDataLen uint64, data io.Reader) (func(so StorageObligation) error, <-chan Output, error)
ExecuteProgram initializes a new program from a set of instructions and a reader which can be used to fetch the program's data and executes it.
type Output ¶
type Output struct { ExecutionCost types.Currency AdditionalCollateral types.Currency PotentialRefund types.Currency // contains filtered or unexported fields }
Output is the type of the outputs returned by a program run on the MDM.
type StorageObligation ¶
type StorageObligation interface { // Update updates the storage obligation. Update(sectorRoots []crypto.Hash, sectorsRemoved map[crypto.Hash]struct{}, sectorsGained map[crypto.Hash][]byte) error }
StorageObligation defines an interface the storage obligation must adhere to.
type StorageObligationSnapshot ¶ added in v1.4.5
type StorageObligationSnapshot interface { // ContractSize returns the current contract size of the storage obligation. ContractSize() uint64 // MerkleRoot returns the filecontract's current root. MerkleRoot() crypto.Hash // SectorRoots returns the roots of the storage obligation. SectorRoots() []crypto.Hash }
StorageObligationSnapshot defines an interface the snapshot must adhere to in order for the mdm to be able to execute a program.