delta

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delta

type Delta struct {
	Data map[string]flow.RegisterEntry
}

A Delta is a record of ledger mutations.

func NewDelta

func NewDelta() Delta

NewDelta returns an empty ledger delta.

func (Delta) Get

func (d Delta) Get(owner, controller, key string) (flow.RegisterValue, bool)

Get reads a register value from this delta.

This function will return nil if the given key has been deleted in this delta. Second return parameters indicated if the value has been set/deleted in this delta

func (Delta) MarshalJSON

func (d Delta) MarshalJSON() ([]byte, error)

func (Delta) MergeWith

func (d Delta) MergeWith(delta Delta)

MergeWith merges this delta with another.

func (Delta) RegisterIDs

func (d Delta) RegisterIDs() []flow.RegisterID

RegisterIDs returns the list of registerIDs inside this delta

func (Delta) RegisterUpdates

func (d Delta) RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)

RegisterUpdates returns all registers that were updated by this delta. ids are returned sorted, in ascending order

func (Delta) Set

func (d Delta) Set(owner, controller, key string, value flow.RegisterValue)

Set records an update in this delta.

func (Delta) UnmarshalJSON

func (d Delta) UnmarshalJSON(data []byte) error

type GetRegisterFunc

type GetRegisterFunc func(owner, controller, key string) (flow.RegisterValue, error)

GetRegisterFunc is a function that returns the value for a register.

type Snapshot

type Snapshot struct {
	Delta Delta
	Reads []flow.RegisterID
}

func (*Snapshot) AllRegisters

func (r *Snapshot) AllRegisters() []flow.RegisterID

AllRegisters returns all the register IDs either in read or delta

func (*Snapshot) RegisterTouches

func (r *Snapshot) RegisterTouches() []flow.RegisterID

RegisterTouches returns the register IDs touched by this view (either read or write)

type SpockSnapshot added in v0.11.0

type SpockSnapshot struct {
	Snapshot
	SpockSecret []byte
}

Snapshot is state of interactions with the register

type View

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

A View is a read-only view into a ledger stored in an underlying data source.

A ledger view records writes to a delta that can be used to update the underlying data source.

func NewView

func NewView(readFunc GetRegisterFunc) *View

NewView instantiates a new ledger view with the provided read function.

func (*View) Delete

func (v *View) Delete(owner, controller, key string)

Delete removes a register in this view.

func (*View) Delta

func (v *View) Delta() Delta

Delta returns a record of the registers that were mutated in this view.

func (*View) Get

func (v *View) Get(owner, controller, key string) (flow.RegisterValue, error)

Get gets a register value from this view.

This function will return an error if it fails to read from the underlying data source for this view.

func (*View) Interactions

func (v *View) Interactions() *SpockSnapshot

Snapshot returns copy of current state of interactions with a View

func (*View) MergeView

func (v *View) MergeView(child *View)

MergeView applies the changes from a the given view to this view. TODO rename this, this is not actually a merge as we can't merge readFunc s.

func (*View) NewChild

func (v *View) NewChild() *View

NewChild generates a new child view, with the current view as the base, sharing the Get function

func (*View) ReadsCount

func (v *View) ReadsCount() uint64

ReadsCount returns the total number of reads performed on this view including all child views

func (*View) RegisterUpdates added in v0.13.0

func (v *View) RegisterUpdates() ([]flow.RegisterID, []flow.RegisterValue)

func (*View) Set

func (v *View) Set(owner, controller, key string, value flow.RegisterValue)

Set sets a register value in this view.

func (*View) SpockSecret

func (v *View) SpockSecret() []byte

SpockSecret returns the secret value for SPoCK

func (*View) Touch

func (v *View) Touch(owner, controller, key string)

Touch explicitly adds a register to the touched registers set.

Jump to

Keyboard shortcuts

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