ledgercore

package
v0.0.0-...-15eb78e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: AGPL-3.0 Imports: 20 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.

View Source
var ErrNoSpace = errors.New("block does not have space for transaction")

ErrNoSpace indicates insufficient space for transaction in block

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 AccountApp

type AccountApp struct {
	Address basics.Address
	App     basics.AppIndex
}

AccountApp is used as a map key.

type AccountAsset

type AccountAsset struct {
	Address basics.Address
	Asset   basics.AssetIndex
}

AccountAsset is used as a map key.

type AccountDeltas

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

AccountDeltas stores ordered accounts and allows fast lookup by address

AccountDeltas는 정렬된 계정들을 저장하고 주소로 빠르게 조회할 수 있게 해준다.

func (*AccountDeltas) CanMarshalMsg

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

(추가)

func (*AccountDeltas) CanUnmarshalMsg

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

(추가)

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) MarshalMsg

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

(추가)MarshalMsg implements msgp.Marshaler

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) MsgIsZero

func (z *AccountDeltas) MsgIsZero() bool

(추가)MsgIsZero returns whether this is a zero value

func (*AccountDeltas) Msgsize

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

(추가)Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AccountDeltas) UnmarshalMsg

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

(추가)UnmarshalMsg implements msgp.Unmarshaler

func (*AccountDeltas) Upsert

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

Upsert adds new or updates existing 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.

AccountTotals는 다른 계정 상태 값으로 그룹화된 시스템의 총 알고양을 나타냅니다. Online, Offline, NotParticipating

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.MicroNovas

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.MicroNovas

Participating returns the sum of algos held under “participating” account status values (Online and Offline). It excludes MicroNovas 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.MicroNovas `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).

AlgoCount는 특정 계정 클래스의 총 알고양을 나타냅니다(상태 값으로 분할됨). => 한 계정이 아니라 특정 클래스(Online, Offline, NotParticipating)의 모든 계정의 합이다!!

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

CatchpointLabel은 단일 catchpoint 레이블을 나타냅니다. 구성 요소를 기반으로 레이블을 "조립"합니다.
캐치업 작업 시 사용하는 라벨로써 라운드, 블록 정보를 가지고 있어 어디까지 작업이 진행됐는지 알려주는 역할을 한다.

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 ErrNonSequentialBlockEval

type ErrNonSequentialBlockEval struct {
	EvaluatorRound basics.Round // EvaluatorRound is the round the evaluator was created for
	LatestRound    basics.Round // LatestRound is the latest round available on disk
}

ErrNonSequentialBlockEval provides feedback when the evaluator cannot be created for stale/future rounds.

func (ErrNonSequentialBlockEval) Error

func (err ErrNonSequentialBlockEval) Error() string

Error satisfies builtin interface `error`

type InitState

type InitState struct {
	Block       bookkeeping.Block
	Accounts    map[basics.Address]basics.AccountData
	GenesisHash crypto.Digest
}

InitState structure defines blockchain init params

블록체인의 초기 파라미터들을 정의하는 구조체

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
	Details string
}

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 creatable state

ModifiedCreatable은 단일 creatable state에 대한 변경 사항을 정의합니다

type OnlineAccount

type OnlineAccount struct {
	// These are a subset of the fields from the corresponding AccountData.
	Address                 basics.Address
	MicroNovas              basics.MicroNovas
	RewardsBase             uint64
	NormalizedOnlineBalance uint64
	VoteFirstValid          basics.Round
	VoteLastValid           basics.Round
	StateProofID            merklesignature.Verifier
}

An OnlineAccount corresponds to an account whose AccountData.Status is Online. This is used for a Merkle tree commitment of online accounts, which is subsequently used to validate participants for a compact certificate.

OnlineAccount는 AccountData.Status가 온라인인 계정에 해당합니다. 이것은 온라인 계정의 Merkle 트리 확정에 사용되며, 이후에 참가자가 컴팩트 인증서에 대해 유효성을 검사하는 데 사용됩니다.

type StateDelta

type StateDelta struct {
	// modified accounts
	/*
		이전 상태에서 수정된 계정들의 정보
	*/
	// 이전과 현재의 계정 정보를 가지고 있는 배열
	Accts AccountDeltas

	// new Txids for the txtail and TxnCounter, mapped to txn.LastValid
	// the txtail과 TxnCounter 그리고 txn.LastValid에 매핑하기 위한 txId
	Txids map[transactions.Txid]basics.Round

	// new txleases for the txtail mapped to expiration
	// 만료에 매핑된 txtail에 대한 새로운 txleases(new txleases for the txtail mapped to expiration)
	Txleases map[Txlease]basics.Round

	// new creatables creator lookup table
	// 단일 creatable(app혹은 asset) state에 대한 변경 사항
	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.
	//우리가 컴팩트 인증서를 기대하는 다음 라운드. 컴팩트 인증서가 예상되지 않으면 0입니다
	CompactCertNext basics.Round

	// previous block timestamp
	// 이전블록의 timestamp
	PrevTimestamp int64

	// Modified local creatable states. The value is true if the creatable local state
	// is created and false if deleted. Used by indexer.
	/*
		local creatable states는 Asset과 App을 말하는 거구나!
		이들이 새로 생성됐다면 true 삭제됐다면 false!
	*/
	ModifiedAssetHoldings  map[AccountAsset]bool
	ModifiedAppLocalStates map[AccountApp]bool

	// The account totals reflecting the changes in this StateDelta object.
	// StateDelta를 반영한 총 계정수
	Totals AccountTotals
	// contains filtered or unexported fields
}

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

StateDelta는 주어진 라운드와 이전 라운드 사이의 델타(차이?)를 나타냅니다.
아 블록뿐만 아니라 계정, 블록헤더, 등 이전라운드와 현재 라운드의 객체들간의 차이를
나타내는 구조체!!

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

MakeStateDelta는 StateDelta의 새 인스턴스를 만듭니다. 힌트는 평가를 위한 총 트랜잭션량, 2 * 힌트는 발신자 및 수신자 잔액 기록용입니다. 대규모 AssetConfig 및 ApplicationCall 트랜잭션에는 적합하지 않습니다.

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 TopOnlineAccounts

type TopOnlineAccounts func(rnd basics.Round, voteRnd basics.Round, n uint64) ([]*OnlineAccount, error)

TopOnlineAccounts is the function signature for a method that would return the top online accounts.

TopOnlineAccounts는 상위 온라인 계정들을 반환하는 메서드에 대한 함수 서명입니다.

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.

Txlease는 트랜잭션의 전송자, lease쌍이다.
이것은 트랜잭션 lease를 고유하게 지정한다.

type ValidatedBlock

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

ValidatedBlock represents the result of a block validation. It can be used to efficiently add the block to the ledger, without repeating the work of applying the block's changes to the ledger state.

ValidatedBlock은 블록 유효성 검사의 결과를 나타냅니다. 원장 상태에 블록의 변경 사항을 적용하는 작업을 반복하지 않고 블록을 원장에 효율적으로 추가할 수 있다.. (StateDelta 덕분인것 같다. StateDelta가 이전 상태와의 차이를 나타내므로 이전에서 변경된 부분만 저장하면 되는 듯하다!!)

func MakeValidatedBlock

func MakeValidatedBlock(blk bookkeeping.Block, delta StateDelta) ValidatedBlock

MakeValidatedBlock creates a validated block.

func (ValidatedBlock) Block

func (vb ValidatedBlock) Block() bookkeeping.Block

Block returns the underlying Block for a ValidatedBlock.

func (ValidatedBlock) Delta

func (vb ValidatedBlock) Delta() StateDelta

Delta returns the underlying Delta for a ValidatedBlock.

func (ValidatedBlock) WithSeed

WithSeed returns a copy of the ValidatedBlock with a modified seed.

type VotersForRound

type VotersForRound struct {

	// Proto is the ConsensusParams for the round whose balances are reflected
	// in participants.
	Proto config.ConsensusParams

	// Participants is the array of top #CompactCertVoters online accounts
	// in this round, sorted by normalized balance (to make sure heavyweight
	// accounts are biased to the front).
	/*
		Participants는 해당 라운드의 투표자들의 배열이다.
	*/
	Participants basics.ParticipantsArray

	// AddrToPos specifies the position of a given account address (if present)
	// in the Participants array.  This allows adding a vote from a given account
	// to the certificate builder.
	AddrToPos map[basics.Address]uint64

	// Tree is a constructed Merkle tree of the Participants array.
	/*
		참가자들 배열의 머클트리
	*/
	Tree *merklearray.Tree

	// TotalWeight is the sum of the weights from the Participants array.
	/*
		참가자들 배열의 총 알고양
	*/
	TotalWeight basics.MicroNovas
	// contains filtered or unexported fields
}

VotersForRound tracks the top online voting accounts as of a particular round, along with a Merkle tree commitment to those voting accounts.

VotersForRound는 특정 라운드의 상위 온라인 투표 계정 및 계정들의 Merkle트리를 추적합니다.

func MakeVotersForRound

func MakeVotersForRound() *VotersForRound

MakeVotersForRound create a new VotersForRound object and initialize it's cond.

func (*VotersForRound) BroadcastError

func (tr *VotersForRound) BroadcastError(err error)

BroadcastError broadcasts the error

func (*VotersForRound) LoadTree

func (tr *VotersForRound) LoadTree(onlineTop TopOnlineAccounts, hdr bookkeeping.BlockHeader) error

LoadTree todo

func (*VotersForRound) Wait

func (tr *VotersForRound) Wait() error

Wait waits for the tree to get constructed.

Jump to

Keyboard shortcuts

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