stool

package
v0.0.0-...-2e68c0b Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HashLength is the number of bytes in a hash
	HashLength = 32
)

Variables

View Source
var (
	// DefaultLeaf is the root of an empty branch
	DefaultLeaf = []byte{0}
)
View Source
var Hasher = func(data ...[]byte) []byte {
	hasher := sha256.New()
	for i := 0; i < len(data); i++ {
		hasher.Write(data[i])
	}
	return hasher.Sum(nil)
}

Hasher is in aergo/internal so cannot be imported at this time

Functions

This section is empty.

Types

type Counters

type Counters struct {
	// -------------- General trie counters only -----------------------------
	// Number of pubkey accounts
	NbUserAccounts uint
	// Number of pubkey accounts with 0 balance
	NbUserAccounts0 uint
	// Number of contract accounts
	NbContracts uint
	// Number of nil objects
	// transaction with amount 0 to a new address creates a balance 0 and nonce 0 account
	NbNilObjects uint
	// Total Aer balace held by accounts (pubkey and contract)
	TotalAerBalance *big.Int

	// -------------- General trie and Contract trie counters ----------------
	// cumulated height (used for calulating avg depth)
	CumulatedHeight int
	AverageDepth    float64
	DeepestLeaf     int

	// -------------- Contract trie counters only ----------------------------
	// Number of storage values (leaves) in the contract trie
	NbStorageValues uint
}

Counters groups counters together

type DbTx

type DbTx interface {
	Set(key, value []byte)
	Delete(key []byte)
}

DbTx represents Set and Delete interface to store data

type Hash

type Hash [32]byte

Hash type of snapshotNodes map keys

type StateAnalysis

type StateAnalysis struct {

	// Counters keeps track of the nb of different types of accounts
	Counters *Counters
	// Trie contains trie reading functionality
	Trie *TrieReader
	// contains filtered or unexported fields
}

StateAnalysis stores the results of dfs

func NewStateAnalysis

func NewStateAnalysis(store db.DB, countDbReads, generalTrie, integrityCheck bool, maxThread uint) *StateAnalysis

NewStateAnalysis initialises StateAnalysis

func (*StateAnalysis) Analyse

func (sa *StateAnalysis) Analyse(root []byte) error

Analyse uses Dfs to analyse and count trie nodes

func (*StateAnalysis) Dfs

func (sa *StateAnalysis) Dfs(root []byte) error

Dfs Depth first search all the trie leaves starting from root For each leaf count it and add it's balance to the total

func (*StateAnalysis) Snapshot

func (sa *StateAnalysis) Snapshot(snapStore db.DB, root []byte) error

Snapshot uses Dfs to copy nodes to a new snapshot db

func (*StateAnalysis) SnapshotAccount

func (sa *StateAnalysis) SnapshotAccount(snapStore db.DB, root, trieKey []byte) error

SnapshotAccount uses Dfs to copy account state nodes and key path to a new snapshot db

type TrieReader

type TrieReader struct {

	// TrieHeight is the number if bits in a key
	TrieHeight int
	// LoadDbCounter counts the nb of db reads in on update
	LoadDbCounter int
	// contains filtered or unexported fields
}

TrieReader provides tools for parsing trie nodes in a db It is a striped down version of the aergo trie package

func NewTrieReader

func NewTrieReader(store db.DB, countDbReads, snapshot bool) *TrieReader

NewTrieReader creates a new TrieReader

func (*TrieReader) LoadChildren

func (s *TrieReader) LoadChildren(root []byte, height, iBatch int, batch [][]byte) ([][]byte, int, []byte, []byte, bool, error)

LoadChildren looks for the children of a node. if the node is not stored in cache, it will be loaded from db.

Jump to

Keyboard shortcuts

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