Documentation
¶
Overview ¶
package ledger implements an append-only ledger where state transitions can be verified
Index ¶
- Constants
- func Constructor(params json.RawMessage, mkSchema schema.Factory) (schema.Schema, error)
- type Iterator
- type Machine
- func (m *Machine[State]) AndThen(ctx context.Context, s schema.RW, r Root[State], next State) (Root[State], error)
- func (m *Machine[State]) GetPrev(ctx context.Context, s schema.RO, root Root[State]) (*Root[State], error)
- func (m *Machine[State]) GetRoot(ctx context.Context, s schema.RO, cid merklelog.CID) (*Root[State], error)
- func (m *Machine[State]) Initial(initState State) Root[State]
- func (m *Machine[State]) NewIterator(s schema.RO, prev Root[State], next Root[State]) *Iterator[State]
- func (m *Machine[State]) Parse(data []byte) (Root[State], error)
- func (m *Machine[State]) PostRoot(ctx context.Context, s schema.WO, root Root[State]) (merklelog.CID, error)
- func (m *Machine[State]) Slot(ctx context.Context, s schema.RO, root Root[State], slot merklelog.Pos) (*Root[State], error)
- func (m *Machine[State]) Validate(ctx context.Context, s schema.RO, prev, next Root[State]) error
- type Marshaler
- type Parser
- type Root
- type Schema
- type Spec
- type VerifyFunc
Constants ¶
View Source
const SchemaName = "blobcache/statetrace"
Variables ¶
This section is empty.
Functions ¶
func Constructor ¶
Types ¶
type Iterator ¶
type Iterator[State Marshaler] struct { // contains filtered or unexported fields }
Iterator is an iterator over all the intermediate states between two roots.
type Machine ¶
type Machine[State Marshaler] struct { HashAlgo blobcache.HashAlgo // ParseState parses a State from a byte slice. ParseState Parser[State] // Verify verifies that prev -> next is a valid transition. // Verify must return nil only if the transition is valid, and never needs to be considered again. Verify VerifyFunc[State] }
Machine performs operations on a ledger.
func (*Machine[State]) AndThen ¶
func (m *Machine[State]) AndThen(ctx context.Context, s schema.RW, r Root[State], next State) (Root[State], error)
AndThen creates a new root with the state. History is updated to reflect the previous state. AndThen does not modify the current root, it returns a new root.
func (*Machine[State]) GetPrev ¶
func (m *Machine[State]) GetPrev(ctx context.Context, s schema.RO, root Root[State]) (*Root[State], error)
GetPrev returns the root, immediately previous to the given root.
func (*Machine[State]) Initial ¶
Initial creates a new root with the given state, and an empty history.
func (*Machine[State]) NewIterator ¶
type Root ¶
type Root[State Marshaler] struct { // History is the history of all previous states. History merklelog.State // State is the current state of the system. State State }
Root is contains transitive references to the entire history and current state of the system.
type Schema ¶
func (*Schema[T]) ValidateChange ¶
Click to show internal directories.
Click to hide internal directories.