mdm

package
v1.4.8-antfarm Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 New

func New(h Host) *MDM

New creates a new MDM.

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.

func (*MDM) Stop

func (mdm *MDM) Stop() error

Stop will stop the MDM and wait for all of the spawned programs to stop executing while also preventing new programs from being started.

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.

Jump to

Keyboard shortcuts

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