ledgercore

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCatchpointParsingFailed = errors.New("catchpoint parsing failed")

ErrCatchpointParsingFailed is used when we attempt to parse and catchpoint label and failing doing so.

Functions

func ParseCatchpointLabel

func ParseCatchpointLabel(label string) (round basics.Round, hash crypto.Digest, err error)

ParseCatchpointLabel parse the given label and breaks it into the round and hash components. In case of a parsing failuire, the returned err is non-nil.

Types

type AccountDeltas

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

AccountDeltas stores ordered accounts and allows fast lookup by address

func (*AccountDeltas) Get

Get lookups AccountData by address

func (*AccountDeltas) GetByIdx

func (ad *AccountDeltas) GetByIdx(i int) (basics.Address, basics.AccountData)

GetByIdx returns address and AccountData It does NOT check boundaries.

func (*AccountDeltas) Len

func (ad *AccountDeltas) Len() int

Len returns number of stored accounts

func (*AccountDeltas) MergeAccounts

func (ad *AccountDeltas) MergeAccounts(other AccountDeltas)

MergeAccounts applies other accounts into this StateDelta accounts

func (*AccountDeltas) ModifiedAccounts

func (ad *AccountDeltas) ModifiedAccounts() []basics.Address

ModifiedAccounts returns list of addresses of modified accounts

func (*AccountDeltas) Upsert

func (ad *AccountDeltas) Upsert(addr basics.Address, data basics.AccountData)

Upsert adds new or updates existing account account

type AccountTotals

type AccountTotals struct {
	Online           AlgoCount `codec:"online"`
	Offline          AlgoCount `codec:"offline"`
	NotParticipating AlgoCount `codec:"notpart"`

	// Total number of algos received per reward unit since genesis
	RewardsLevel uint64 `codec:"rwdlvl"`
	// contains filtered or unexported fields
}

AccountTotals represents the totals of algos in the system grouped by different account status values.

func (*AccountTotals) AddAccount

func (at *AccountTotals) AddAccount(proto config.ConsensusParams, data basics.AccountData, ot *basics.OverflowTracker)

AddAccount adds an account algos from the total money

func (*AccountTotals) All

func (at *AccountTotals) All() basics.MicroAlgos

All returns the sum of algos held under all different status values.

func (*AccountTotals) ApplyRewards

func (at *AccountTotals) ApplyRewards(rewardsLevel uint64, ot *basics.OverflowTracker)

ApplyRewards adds the reward to the account totals based on the new rewards level

func (*AccountTotals) CanMarshalMsg

func (_ *AccountTotals) CanMarshalMsg(z interface{}) bool

func (*AccountTotals) CanUnmarshalMsg

func (_ *AccountTotals) CanUnmarshalMsg(z interface{}) bool

func (*AccountTotals) DelAccount

func (at *AccountTotals) DelAccount(proto config.ConsensusParams, data basics.AccountData, ot *basics.OverflowTracker)

DelAccount removes an account algos from the total money

func (*AccountTotals) MarshalMsg

func (z *AccountTotals) MarshalMsg(b []byte) (o []byte)

MarshalMsg implements msgp.Marshaler

func (*AccountTotals) MsgIsZero

func (z *AccountTotals) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*AccountTotals) Msgsize

func (z *AccountTotals) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AccountTotals) Participating

func (at *AccountTotals) Participating() basics.MicroAlgos

Participating returns the sum of algos held under “participating” account status values (Online and Offline). It excludes MicroAlgos held by NotParticipating accounts.

func (*AccountTotals) RewardUnits

func (at *AccountTotals) RewardUnits() uint64

RewardUnits returns the sum of reward units held under “participating” account status values (Online and Offline). It excludes units held by NotParticipating accounts.

func (*AccountTotals) UnmarshalMsg

func (z *AccountTotals) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type AlgoCount

type AlgoCount struct {

	// Sum of algos of all accounts in this class.
	Money basics.MicroAlgos `codec:"mon"`

	// Total number of whole reward units in accounts.
	RewardUnits uint64 `codec:"rwd"`
	// contains filtered or unexported fields
}

AlgoCount represents a total of algos of a certain class of accounts (split up by their Status value).

func (*AlgoCount) CanMarshalMsg

func (_ *AlgoCount) CanMarshalMsg(z interface{}) bool

func (*AlgoCount) CanUnmarshalMsg

func (_ *AlgoCount) CanUnmarshalMsg(z interface{}) bool

func (*AlgoCount) MarshalMsg

func (z *AlgoCount) MarshalMsg(b []byte) (o []byte)

MarshalMsg implements msgp.Marshaler

func (*AlgoCount) MsgIsZero

func (z *AlgoCount) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*AlgoCount) Msgsize

func (z *AlgoCount) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AlgoCount) UnmarshalMsg

func (z *AlgoCount) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BlockInLedgerError

type BlockInLedgerError struct {
	LastRound basics.Round
	NextRound basics.Round
}

BlockInLedgerError is returned when a block cannot be added because it has already been done

func (BlockInLedgerError) Error

func (bile BlockInLedgerError) Error() string

Error satisfies builtin interface `error`

type CatchpointLabel

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

CatchpointLabel represent a single catchpoint label. It will "assemble" a label based on the components

func MakeCatchpointLabel

func MakeCatchpointLabel(ledgerRound basics.Round, ledgerRoundBlockHash crypto.Digest, balancesMerkleRoot crypto.Digest, totals AccountTotals) CatchpointLabel

MakeCatchpointLabel creates a catchpoint label given the catchpoint label parameters.

func (CatchpointLabel) Hash

func (l CatchpointLabel) Hash() crypto.Digest

Hash return the hash portion of this catchpoint label

func (CatchpointLabel) String

func (l CatchpointLabel) String() string

String return the user-facing representation of this catchpoint label. ( i.e. the "label" )

type ErrNoEntry

type ErrNoEntry struct {
	Round     basics.Round
	Latest    basics.Round
	Committed basics.Round
}

ErrNoEntry is used to indicate that a block is not present in the ledger.

func (ErrNoEntry) Error

func (err ErrNoEntry) Error() string

Error satisfies builtin interface `error`

type LeaseInLedgerError

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

LeaseInLedgerError is returned when a transaction cannot be added because it has a lease that already being used in the relavant rounds

func MakeLeaseInLedgerError

func MakeLeaseInLedgerError(txid transactions.Txid, lease Txlease) *LeaseInLedgerError

MakeLeaseInLedgerError builds a LeaseInLedgerError object

func (*LeaseInLedgerError) Error

func (lile *LeaseInLedgerError) Error() string

Error implements the error interface for the LeaseInLedgerError stuct

type LogicEvalError

type LogicEvalError struct {
	Err error
}

LogicEvalError indicates TEAL evaluation failure

func (LogicEvalError) Error

func (err LogicEvalError) Error() string

Error satisfies builtin interface `error`

type ModifiedCreatable

type ModifiedCreatable struct {
	// Type of the creatable: app or asset
	Ctype basics.CreatableType

	// Created if true, deleted if false
	Created bool

	// creator of the app/asset
	Creator basics.Address

	// Keeps track of how many times this app/asset appears in
	// accountUpdates.creatableDeltas
	Ndeltas int
}

ModifiedCreatable defines the changes to a single single creatable state

type StateDelta

type StateDelta struct {
	// modified accounts
	Accts AccountDeltas

	// new Txids for the txtail and TxnCounter, mapped to txn.LastValid
	Txids map[transactions.Txid]basics.Round

	// new txleases for the txtail mapped to expiration
	Txleases map[Txlease]basics.Round

	// new creatables creator lookup table
	Creatables map[basics.CreatableIndex]ModifiedCreatable

	// new block header; read-only
	Hdr *bookkeeping.BlockHeader

	// next round for which we expect a compact cert.
	// zero if no compact cert is expected.
	CompactCertNext basics.Round

	// previous block timestamp
	PrevTimestamp int64
	// contains filtered or unexported fields
}

StateDelta describes the delta between a given round to the previous round

func MakeStateDelta

func MakeStateDelta(hdr *bookkeeping.BlockHeader, prevTimestamp int64, hint int, compactCertNext basics.Round) StateDelta

MakeStateDelta creates a new instance of StateDelta. hint is amount of transactions for evaluation, 2 * hint is for sender and receiver balance records. This does not play well for AssetConfig and ApplicationCall transactions on scale

func (*StateDelta) OptimizeAllocatedMemory

func (sd *StateDelta) OptimizeAllocatedMemory(proto config.ConsensusParams)

OptimizeAllocatedMemory by reallocating maps to needed capacity For each data structure, reallocate if it would save us at least 50MB aggregate

type TransactionInLedgerError

type TransactionInLedgerError struct {
	Txid transactions.Txid
}

TransactionInLedgerError is returned when a transaction cannot be added because it has already been done

func (TransactionInLedgerError) Error

func (tile TransactionInLedgerError) Error() string

Error satisfies builtin interface `error`

type Txlease

type Txlease struct {
	Sender basics.Address
	Lease  [32]byte
}

A Txlease is a transaction (sender, lease) pair which uniquely specifies a transaction lease.

Jump to

Keyboard shortcuts

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