state

package
v0.0.0-...-6d4bf48 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snapshot

type Snapshot struct {
	Tree   *patricia.Tree
	Nonces map[bc.Hash]uint64
}

Snapshot encompasses a snapshot of entire blockchain state. It consists of a patricia state tree and the nonce set.

Nonces maps a nonce entry's ID to the time (in Unix millis) at which it should expire from the nonce set.

TODO: consider making type Snapshot truly immutable. We already handle it that way in many places (with explicit calls to Copy to get the right behavior). PruneNonces and the Apply functions would have to produce new Snapshots rather than updating Snapshots in place.

func Copy

func Copy(original *Snapshot) *Snapshot

Copy makes a copy of provided snapshot. Copying a snapshot is an O(n) operation where n is the number of nonces in the snapshot's nonce set.

func Empty

func Empty() *Snapshot

Empty returns an empty state snapshot.

func (*Snapshot) ApplyBlock

func (s *Snapshot) ApplyBlock(block *bc.Block) error

ApplyBlock updates s in place.

func (*Snapshot) ApplyTx

func (s *Snapshot) ApplyTx(tx *bc.Tx) error

ApplyTx updates s in place.

func (*Snapshot) PruneNonces

func (s *Snapshot) PruneNonces(timestampMS uint64)

PruneNonces modifies a Snapshot, removing all nonce IDs with expiration times earlier than the provided timestamp.

Jump to

Keyboard shortcuts

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