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 ¶
This section is empty.
Types ¶
type FnFinalize ¶ added in v1.4.9
type FnFinalize func(StorageObligation) error
FnFinalize is the type of a function returned by ExecuteProgram to finalize the changes made by the program.
type Host ¶
type Host interface { BlockHeight() types.BlockHeight HasSector(crypto.Hash) bool ReadSector(sectorRoot crypto.Hash) ([]byte, error) RegistryUpdate(rv modules.SignedRegistryValue, pubKey types.SiaPublicKey, expiry types.BlockHeight) (modules.SignedRegistryValue, error) RegistryGet(sid modules.RegistryEntryID) (types.SiaPublicKey, modules.SignedRegistryValue, bool) }
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, duration types.BlockHeight, programDataLen uint64, data io.Reader) (_ FnFinalize, _ <-chan Output, err 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 { // Batch indicates whether or not the caller is recommended to hold off on // sending the output over the wire in favor of batching the writes with the // result of the next instruction. Batch bool // ExecutionCost contains the running program value for the execution cost. ExecutionCost types.Currency // AdditionalCollateral contains the running program value for the // additional collateral. AdditionalCollateral types.Currency // FailureRefund is the amount of money that gets refunded should the // program execution fail. FailureRefund 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 // RecentRevision returns the recent revision at the time the snapshot was // taken. RecentRevision() types.FileContractRevision // RevisionTxn returns the recent revision txn of the so. RevisionTxn() types.Transaction // 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.
Source Files ¶
- instruction.go
- instructionappend.go
- instructiondropsectors.go
- instructionhassector.go
- instructionreadoffset.go
- instructionreadregistry.go
- instructionreadregistrysid.go
- instructionreadsector.go
- instructionrevision.go
- instructionswapsector.go
- instructionupdateregistry.go
- mdm.go
- program.go
- programdata.go
- sectors.go