Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptableCompactCertWeight(votersHdr bookkeeping.BlockHeader, firstValid basics.Round, ...) uint64
- func CompactCertParams(votersHdr bookkeeping.BlockHeader, hdr bookkeeping.BlockHeader) (res compactcert.Params, err error)
- func EvalForIndexer(il indexerLedgerForEval, block *bookkeeping.Block, ...) (ledgercore.StateDelta, []transactions.SignedTxnInBlock, error)
- func MakeDebugBalances(l DebuggerLedger, round basics.Round, proto protocol.ConsensusVersion, ...) apply.Balances
- type BlockListener
- type CatchpointCatchupAccessor
- type CatchpointCatchupAccessorImpl
- func (c *CatchpointCatchupAccessorImpl) BuildMerkleTrie(ctx context.Context, progressUpdates func(uint64)) (err error)
- func (c *CatchpointCatchupAccessorImpl) CompleteCatchup(ctx context.Context) (err error)
- func (c *CatchpointCatchupAccessorImpl) EnsureFirstBlock(ctx context.Context) (blk bookkeeping.Block, err error)
- func (c *CatchpointCatchupAccessorImpl) FinishBlocks(ctx context.Context, applyChanges bool) (err error)
- func (c *CatchpointCatchupAccessorImpl) GetCatchupBlockRound(ctx context.Context) (round basics.Round, err error)
- func (c *CatchpointCatchupAccessorImpl) GetLabel(ctx context.Context) (label string, err error)
- func (c *CatchpointCatchupAccessorImpl) GetState(ctx context.Context) (state CatchpointCatchupState, err error)
- func (c *CatchpointCatchupAccessorImpl) ProgressStagingBalances(ctx context.Context, sectionName string, bytes []byte, ...) (err error)
- func (c *CatchpointCatchupAccessorImpl) ResetStagingBalances(ctx context.Context, newCatchup bool) (err error)
- func (c *CatchpointCatchupAccessorImpl) SetLabel(ctx context.Context, label string) (err error)
- func (c *CatchpointCatchupAccessorImpl) SetState(ctx context.Context, state CatchpointCatchupState) (err error)
- func (c *CatchpointCatchupAccessorImpl) StoreBalancesRound(ctx context.Context, blk *bookkeeping.Block) (err error)
- func (c *CatchpointCatchupAccessorImpl) StoreBlock(ctx context.Context, blk *bookkeeping.Block) (err error)
- func (c *CatchpointCatchupAccessorImpl) StoreFirstBlock(ctx context.Context, blk *bookkeeping.Block) (err error)
- func (c *CatchpointCatchupAccessorImpl) VerifyCatchpoint(ctx context.Context, blk *bookkeeping.Block) (err error)
- type CatchpointCatchupAccessorProgress
- type CatchpointCatchupState
- func (_ CatchpointCatchupState) CanMarshalMsg(z interface{}) bool
- func (_ *CatchpointCatchupState) CanUnmarshalMsg(z interface{}) bool
- func (z CatchpointCatchupState) MarshalMsg(b []byte) (o []byte)
- func (z CatchpointCatchupState) MsgIsZero() bool
- func (z CatchpointCatchupState) Msgsize() (s int)
- func (z *CatchpointCatchupState) UnmarshalMsg(bts []byte) (o []byte, err error)
- type CatchpointFileHeader
- func (_ *CatchpointFileHeader) CanMarshalMsg(z interface{}) bool
- func (_ *CatchpointFileHeader) CanUnmarshalMsg(z interface{}) bool
- func (z *CatchpointFileHeader) MarshalMsg(b []byte) (o []byte)
- func (z *CatchpointFileHeader) MsgIsZero() bool
- func (z *CatchpointFileHeader) Msgsize() (s int)
- func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Creatable
- type DebuggerLedger
- type EvalForIndexerResources
- type FoundAddress
- type Ledger
- func (l *Ledger) AddBlock(blk bookkeeping.Block, cert agreement.Certificate) error
- func (l *Ledger) AddValidatedBlock(vb ledgercore.ValidatedBlock, cert agreement.Certificate) error
- func (l *Ledger) Block(rnd basics.Round) (blk bookkeeping.Block, err error)
- func (l *Ledger) BlockCert(rnd basics.Round) (blk bookkeeping.Block, cert agreement.Certificate, err error)
- func (l *Ledger) BlockHdr(rnd basics.Round) (blk bookkeeping.BlockHeader, err error)
- func (l *Ledger) CheckDup(currentProto config.ConsensusParams, current basics.Round, ...) error
- func (l *Ledger) Close()
- func (l *Ledger) CompactCertVoters(rnd basics.Round) (*ledgercore.VotersForRound, error)
- func (l *Ledger) EncodedBlockCert(rnd basics.Round) (blk []byte, cert []byte, err error)
- func (l *Ledger) GenesisAccounts() map[basics.Address]basics.AccountData
- func (l *Ledger) GenesisHash() crypto.Digest
- func (l *Ledger) GenesisProto() config.ConsensusParams
- func (l *Ledger) GetCatchpointCatchupState(ctx context.Context) (state CatchpointCatchupState, err error)
- func (l *Ledger) GetCatchpointStream(round basics.Round) (ReadCloseSizer, error)
- func (l *Ledger) GetCreator(cidx basics.CreatableIndex, ctype basics.CreatableType) (basics.Address, bool, error)
- func (l *Ledger) GetCreatorForRound(rnd basics.Round, cidx basics.CreatableIndex, ctype basics.CreatableType) (creator basics.Address, ok bool, err error)
- func (l *Ledger) GetLastCatchpointLabel() string
- func (l *Ledger) GetLedgerRootDir() string
- func (ledger *Ledger) GetTrackerDbs() db.Pair
- func (l *Ledger) IsWritingCatchpointFile() bool
- func (l *Ledger) Latest() basics.Round
- func (l *Ledger) LatestCommitted() (basics.Round, basics.Round)
- func (l *Ledger) LatestTotals() (basics.Round, ledgercore.AccountTotals, error)
- func (l *Ledger) ListApplications(maxAppIdx basics.AppIndex, maxResults uint64) (results []basics.CreatableLocator, err error)
- func (l *Ledger) ListAssets(maxAssetIdx basics.AssetIndex, maxResults uint64) (results []basics.CreatableLocator, err error)
- func (l *Ledger) Lookup(rnd basics.Round, addr basics.Address) (basics.AccountData, error)
- func (l *Ledger) LookupAgreement(rnd basics.Round, addr basics.Address) (basics.OnlineAccountData, error)
- func (l *Ledger) LookupWithoutRewards(rnd basics.Round, addr basics.Address) (basics.AccountData, basics.Round, error)
- func (l *Ledger) OnlineTotals(rnd basics.Round) (basics.MicroNovas, error)
- func (l *Ledger) RegisterBlockListeners(listeners []BlockListener)
- func (l *Ledger) RegisterBlockTrackingListener(listener ValidateBlockListener)
- func (l *Ledger) SetLedgerRootDir(directory string)
- func (l *Ledger) StartEvaluator(hdr bookkeeping.BlockHeader, paysetHint, maxTxnBytesPerBlock int) (*internal.BlockEvaluator, error)
- func (l *Ledger) Validate(ctx context.Context, blk bookkeeping.Block, executionPool execpool.BacklogPool) (*ledgercore.ValidatedBlock, error)
- func (l *Ledger) VerifiedTransactionCache() verify.VerifiedTransactionCache
- func (l *Ledger) Wait(r basics.Round) chan struct{}
- func (l *Ledger) WaitForCommit(r basics.Round)
- type MerkleCommitter
- type MismatchingDatabaseRoundError
- type ReadCloseSizer
- type RoundOffsetError
- type StaleDatabaseRoundError
- type ValidateBlockListener
Constants ¶
const ( // CatchpointCatchupStateInactive is the common state for the catchpoint catchup - not active. CatchpointCatchupStateInactive = iota // CatchpointCatchupStateLedgerDownload indicates that we're downloading the ledger CatchpointCatchupStateLedgerDownload // CatchpointCatchupStateLastestBlockDownload indicates that we're download the latest block CatchpointCatchupStateLastestBlockDownload // CatchpointCatchupStateBlocksDownload indicates that we're downloading the blocks prior to the latest one ( total of MaxBalLookback blocks ) CatchpointCatchupStateBlocksDownload // CatchpointCatchupStateSwitch indicates that we're switching to use the downloaded ledger/blocks content CatchpointCatchupStateSwitch )
const ( // BalancesPerCatchpointFileChunk defines the number of accounts that would be stored in each chunk in the catchpoint file. // note that the last chunk would typically be less than this number. /* BalancesPerCatchpointFileChunk는 캐치포인트 파일의 각 청크(계정의 묶음)에 저장될 계정 수를 정의합니다. 마지막 청크는 일반적으로 이 숫자보다 작습니다 */ BalancesPerCatchpointFileChunk = 512 )
const MaxInt = int((^uint(0)) >> 1)
MaxInt is the maximum int which might be int32 or int64
Variables ¶
var TrieMemoryConfig = merkletrie.MemoryConfig{
NodesCountPerPage: merkleCommitterNodesPerPage,
CachedNodesCount: trieCachedNodesCount,
PageFillFactor: 0.95,
MaxChildrenPagesThreshold: 64,
}
TrieMemoryConfig is the memory configuration setup used for the merkle trie.
Functions ¶
func AcceptableCompactCertWeight ¶
func AcceptableCompactCertWeight(votersHdr bookkeeping.BlockHeader, firstValid basics.Round, logger logging.Logger) uint64
AcceptableCompactCertWeight computes the acceptable signed weight of a compact cert if it were to appear in a transaction with a particular firstValid round. Earlier rounds require a smaller cert. votersHdr specifies the block that contains the Merkle commitment of the voters for this compact cert (and thus the compact cert is for votersHdr.Round() + CompactCertRounds).
logger must not be nil; use at least logging.Base()
func CompactCertParams ¶
func CompactCertParams(votersHdr bookkeeping.BlockHeader, hdr bookkeeping.BlockHeader) (res compactcert.Params, err error)
CompactCertParams computes the parameters for building or verifying a compact cert for block hdr, using voters from block votersHdr.
func EvalForIndexer ¶
func EvalForIndexer(il indexerLedgerForEval, block *bookkeeping.Block, proto config.ConsensusParams, resources EvalForIndexerResources) (ledgercore.StateDelta, []transactions.SignedTxnInBlock, error)
EvalForIndexer evaluates a block without validation using the given `proto`. Return the state delta and transactions with modified apply data according to `proto`. This function is used by Indexer which modifies `proto` to retrieve the asset close amount for each transaction even when the real consensus parameters do not support it.
func MakeDebugBalances ¶
func MakeDebugBalances(l DebuggerLedger, round basics.Round, proto protocol.ConsensusVersion, prevTimestamp int64) apply.Balances
MakeDebugBalances creates a ledger suitable for dryrun and debugger
Types ¶
type BlockListener ¶
type BlockListener interface {
OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta)
}
BlockListener represents an object that needs to get notified on new blocks. BlockListener는 새 블록에 대해 알림을 받아야 하는 개체를 나타냅니다.
BlockListener는 새 블록에 대한 알림을 받아야 하는 개체를 나타냅니다. 즉, 블록이 생성되면 그것을 인지할 수 있어야 한다.
type CatchpointCatchupAccessor ¶
type CatchpointCatchupAccessor interface { // GetState returns the current state of the catchpoint catchup GetState(ctx context.Context) (state CatchpointCatchupState, err error) // SetState set the state of the catchpoint catchup SetState(ctx context.Context, state CatchpointCatchupState) (err error) // GetLabel returns the current catchpoint catchup label GetLabel(ctx context.Context) (label string, err error) // SetLabel set the catchpoint catchup label SetLabel(ctx context.Context, label string) (err error) // ResetStagingBalances resets the current staging balances, preparing for a new set of balances to be added ResetStagingBalances(ctx context.Context, newCatchup bool) (err error) // ProgressStagingBalances deserialize the given bytes as a temporary staging balances ProgressStagingBalances(ctx context.Context, sectionName string, bytes []byte, progress *CatchpointCatchupAccessorProgress) (err error) // BuildMerkleTrie inserts the account hashes into the merkle trie BuildMerkleTrie(ctx context.Context, progressUpdates func(uint64)) (err error) // GetCatchupBlockRound returns the latest block round matching the current catchpoint GetCatchupBlockRound(ctx context.Context) (round basics.Round, err error) // VerifyCatchpoint verifies that the catchpoint is valid by reconstructing the label. VerifyCatchpoint(ctx context.Context, blk *bookkeeping.Block) (err error) // StoreBalancesRound calculates the balances round based on the first block and the associated consensus parameters, and // store that to the database StoreBalancesRound(ctx context.Context, blk *bookkeeping.Block) (err error) // StoreFirstBlock stores a single block to the blocks database. StoreFirstBlock(ctx context.Context, blk *bookkeeping.Block) (err error) // StoreBlock stores a single block to the blocks database. StoreBlock(ctx context.Context, blk *bookkeeping.Block) (err error) // FinishBlocks concludes the catchup of the blocks database. FinishBlocks(ctx context.Context, applyChanges bool) (err error) // EnsureFirstBlock ensure that we have a single block in the staging block table, and returns that block EnsureFirstBlock(ctx context.Context) (blk bookkeeping.Block, err error) // CompleteCatchup completes the catchpoint catchup process by switching the databases tables around // and reloading the ledger. CompleteCatchup(ctx context.Context) (err error) }
CatchpointCatchupAccessor is an interface for the accessor wrapping the database storage for the catchpoint catchup functionality.
CatchpointCatchupAccessor는 캐치포인트 캐치업 기능을 위해 데이터베이스 스토리지를 래핑한 접근자에 대한 인터페이스입니다 (캐치포인트 캐치업 기능이 뭘까? 블록체인 스냅샷(catchpoint)를 사용해 동기화(catchup)를 몇분안에 할 수 있게 해주는 기술)
catchpoint file에 있는 내용을 디코딩해서 데이터베이스에 정보를 저장한다.
func MakeCatchpointCatchupAccessor ¶
func MakeCatchpointCatchupAccessor(ledger *Ledger, log logging.Logger) CatchpointCatchupAccessor
MakeCatchpointCatchupAccessor creates a CatchpointCatchupAccessor given a ledger
type CatchpointCatchupAccessorImpl ¶
type CatchpointCatchupAccessorImpl struct {
// contains filtered or unexported fields
}
CatchpointCatchupAccessorImpl is the concrete implementation of the CatchpointCatchupAccessor interface
func (*CatchpointCatchupAccessorImpl) BuildMerkleTrie ¶
func (c *CatchpointCatchupAccessorImpl) BuildMerkleTrie(ctx context.Context, progressUpdates func(uint64)) (err error)
BuildMerkleTrie would process the catchpointpendinghashes and insert all the items in it into the merkle trie
func (*CatchpointCatchupAccessorImpl) CompleteCatchup ¶
func (c *CatchpointCatchupAccessorImpl) CompleteCatchup(ctx context.Context) (err error)
CompleteCatchup completes the catchpoint catchup process by switching the databases tables around and reloading the ledger.
func (*CatchpointCatchupAccessorImpl) EnsureFirstBlock ¶
func (c *CatchpointCatchupAccessorImpl) EnsureFirstBlock(ctx context.Context) (blk bookkeeping.Block, err error)
EnsureFirstBlock ensure that we have a single block in the staging block table, and returns that block
func (*CatchpointCatchupAccessorImpl) FinishBlocks ¶
func (c *CatchpointCatchupAccessorImpl) FinishBlocks(ctx context.Context, applyChanges bool) (err error)
FinishBlocks concludes the catchup of the blocks database.
func (*CatchpointCatchupAccessorImpl) GetCatchupBlockRound ¶
func (c *CatchpointCatchupAccessorImpl) GetCatchupBlockRound(ctx context.Context) (round basics.Round, err error)
GetCatchupBlockRound returns the latest block round matching the current catchpoint
func (*CatchpointCatchupAccessorImpl) GetLabel ¶
func (c *CatchpointCatchupAccessorImpl) GetLabel(ctx context.Context) (label string, err error)
GetLabel returns the current catchpoint catchup label
func (*CatchpointCatchupAccessorImpl) GetState ¶
func (c *CatchpointCatchupAccessorImpl) GetState(ctx context.Context) (state CatchpointCatchupState, err error)
GetState returns the current state of the catchpoint catchup
func (*CatchpointCatchupAccessorImpl) ProgressStagingBalances ¶
func (c *CatchpointCatchupAccessorImpl) ProgressStagingBalances(ctx context.Context, sectionName string, bytes []byte, progress *CatchpointCatchupAccessorProgress) (err error)
ProgressStagingBalances deserialize the given bytes as a temporary staging balances
func (*CatchpointCatchupAccessorImpl) ResetStagingBalances ¶
func (c *CatchpointCatchupAccessorImpl) ResetStagingBalances(ctx context.Context, newCatchup bool) (err error)
ResetStagingBalances resets the current staging balances, preparing for a new set of balances to be added
func (*CatchpointCatchupAccessorImpl) SetLabel ¶
func (c *CatchpointCatchupAccessorImpl) SetLabel(ctx context.Context, label string) (err error)
SetLabel set the catchpoint catchup label
func (*CatchpointCatchupAccessorImpl) SetState ¶
func (c *CatchpointCatchupAccessorImpl) SetState(ctx context.Context, state CatchpointCatchupState) (err error)
SetState set the state of the catchpoint catchup
func (*CatchpointCatchupAccessorImpl) StoreBalancesRound ¶
func (c *CatchpointCatchupAccessorImpl) StoreBalancesRound(ctx context.Context, blk *bookkeeping.Block) (err error)
StoreBalancesRound calculates the balances round based on the first block and the associated consensus parameters, and store that to the database
func (*CatchpointCatchupAccessorImpl) StoreBlock ¶
func (c *CatchpointCatchupAccessorImpl) StoreBlock(ctx context.Context, blk *bookkeeping.Block) (err error)
StoreBlock stores a single block to the blocks database.
func (*CatchpointCatchupAccessorImpl) StoreFirstBlock ¶
func (c *CatchpointCatchupAccessorImpl) StoreFirstBlock(ctx context.Context, blk *bookkeeping.Block) (err error)
StoreFirstBlock stores a single block to the blocks database.
func (*CatchpointCatchupAccessorImpl) VerifyCatchpoint ¶
func (c *CatchpointCatchupAccessorImpl) VerifyCatchpoint(ctx context.Context, blk *bookkeeping.Block) (err error)
VerifyCatchpoint verifies that the catchpoint is valid by reconstructing the label.
type CatchpointCatchupAccessorProgress ¶
type CatchpointCatchupAccessorProgress struct { TotalAccounts uint64 ProcessedAccounts uint64 ProcessedBytes uint64 TotalChunks uint64 SeenHeader bool // contains filtered or unexported fields }
CatchpointCatchupAccessorProgress is used by the caller of ProgressStagingBalances to obtain progress information
type CatchpointCatchupState ¶
type CatchpointCatchupState int32
CatchpointCatchupState is the state of the current catchpoint catchup process
func (CatchpointCatchupState) CanMarshalMsg ¶
func (_ CatchpointCatchupState) CanMarshalMsg(z interface{}) bool
func (*CatchpointCatchupState) CanUnmarshalMsg ¶
func (_ *CatchpointCatchupState) CanUnmarshalMsg(z interface{}) bool
func (CatchpointCatchupState) MarshalMsg ¶
func (z CatchpointCatchupState) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (CatchpointCatchupState) MsgIsZero ¶
func (z CatchpointCatchupState) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (CatchpointCatchupState) Msgsize ¶
func (z CatchpointCatchupState) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*CatchpointCatchupState) UnmarshalMsg ¶
func (z *CatchpointCatchupState) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type CatchpointFileHeader ¶
type CatchpointFileHeader struct { Version uint64 `codec:"version"` BalancesRound basics.Round `codec:"balancesRound"` BlocksRound basics.Round `codec:"blocksRound"` Totals ledgercore.AccountTotals `codec:"accountTotals"` TotalAccounts uint64 `codec:"accountsCount"` TotalChunks uint64 `codec:"chunksCount"` Catchpoint string `codec:"catchpoint"` BlockHeaderDigest crypto.Digest `codec:"blockHeaderDigest"` // contains filtered or unexported fields }
CatchpointFileHeader is the content we would have in the "content.msgpack" file in the catchpoint tar archive. we need it to be public, as it's being decoded externally by the catchpointdump utility.
CatchpointFileHeader는 catchpoint.tar 아카이브의 "content.msgpack" 파일에 있는 내용입니다. catchpointdump 유틸리티에 의해 외부적으로 디코딩되기 때문에 공개되어야 합니다
func (*CatchpointFileHeader) CanMarshalMsg ¶
func (_ *CatchpointFileHeader) CanMarshalMsg(z interface{}) bool
func (*CatchpointFileHeader) CanUnmarshalMsg ¶
func (_ *CatchpointFileHeader) CanUnmarshalMsg(z interface{}) bool
func (*CatchpointFileHeader) MarshalMsg ¶
func (z *CatchpointFileHeader) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (*CatchpointFileHeader) MsgIsZero ¶
func (z *CatchpointFileHeader) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (*CatchpointFileHeader) Msgsize ¶
func (z *CatchpointFileHeader) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*CatchpointFileHeader) UnmarshalMsg ¶
func (z *CatchpointFileHeader) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Creatable ¶
type Creatable struct { Index basics.CreatableIndex Type basics.CreatableType }
Creatable represent a single creatable object.
type DebuggerLedger ¶
type DebuggerLedger = internal.LedgerForCowBase
DebuggerLedger defines the minimal set of method required for creating a debug balances.
type EvalForIndexerResources ¶
type EvalForIndexerResources struct { // The map value is nil iff the account does not exist. The account data is owned here. Accounts map[basics.Address]*basics.AccountData Creators map[Creatable]FoundAddress }
EvalForIndexerResources contains resources preloaded from the Indexer database. Indexer is able to do the preloading more efficiently than the evaluator loading resources one by one.
EvalForIndexerResources에는 인덱서 데이터베이스에서 미리 로드된 리소스가 포함되어 있습니다. 인덱서는 리소스를 하나씩 로드하는 evaluator보다 효율적으로 사전 로드를 수행할 수 있습니다.
type FoundAddress ¶
FoundAddress is a wrapper for an address and a boolean.
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
func OpenLedger ¶
func OpenLedger( log logging.Logger, dbPathPrefix string, dbMem bool, genesisInitState ledgercore.InitState, cfg config.Local, ) (*Ledger, error)
OpenLedger creates a Ledger object, using SQLite database filenames based on dbPathPrefix (in-memory if dbMem is true). genesisInitState.Blocks and genesisInitState.Accounts specify the initial blocks and accounts to use if the database wasn't initialized before.
원장객체를 생성한다. db가 이전에 초기화 된적이 없다면 최초 블록들과 계정들을 초기화한다.
func (*Ledger) AddBlock ¶
func (l *Ledger) AddBlock(blk bookkeeping.Block, cert agreement.Certificate) error
AddBlock adds a new block to the ledger. The block is stored in an in-memory queue and is written to the disk in the background. An error is returned if this is not the expected next block number.
새로운 블록을 원장에 등록한다. 블록은 in-memory큐에 저장되고(블록큐!아 이게 heap에 있나보네 즉, 프로세스에서만 유지되는!) 백그라운드에서 디스크(영구저장영역 - hdd나 sdd)에 저장도니다.
func (*Ledger) AddValidatedBlock ¶
func (l *Ledger) AddValidatedBlock(vb ledgercore.ValidatedBlock, cert agreement.Certificate) error
AddValidatedBlock adds a new block to the ledger, after the block has been validated by calling Ledger.Validate(). This saves the cost of having to re-compute the effect of the block on the ledger state, if the block has previously been validated. Otherwise, AddValidatedBlock behaves like AddBlock.
검증된 블록을 원장에 저장한다. 만약 검증된 블록이라면 검증을 위한 계산을 하지 않지만 그렇지 않다면 AddBlock와 동일하게 작동한다(검증을 하는 것 같다.)
func (*Ledger) BlockCert ¶
func (l *Ledger) BlockCert(rnd basics.Round) (blk bookkeeping.Block, cert agreement.Certificate, err error)
BlockCert returns the block and the certificate of the block for round rnd.
func (*Ledger) BlockHdr ¶
func (l *Ledger) BlockHdr(rnd basics.Round) (blk bookkeeping.BlockHeader, err error)
BlockHdr returns the BlockHeader of the block for round rnd.
func (*Ledger) CheckDup ¶
func (l *Ledger) CheckDup(currentProto config.ConsensusParams, current basics.Round, firstValid basics.Round, lastValid basics.Round, txid transactions.Txid, txl ledgercore.Txlease) error
CheckDup return whether a transaction is a duplicate one.
func (*Ledger) Close ¶
func (l *Ledger) Close()
Close reclaims resources used by the ledger (namely, the database connection and goroutines used by trackers).
func (*Ledger) CompactCertVoters ¶
func (l *Ledger) CompactCertVoters(rnd basics.Round) (*ledgercore.VotersForRound, error)
CompactCertVoters returns the top online accounts at round rnd. The result might be nil, even with err=nil, if there are no voters for that round because compact certs were not enabled.
func (*Ledger) EncodedBlockCert ¶
EncodedBlockCert returns the encoded block and the corresponding encoded certificate of the block for round rnd.
func (*Ledger) GenesisAccounts ¶
func (l *Ledger) GenesisAccounts() map[basics.Address]basics.AccountData
GenesisAccounts returns initial accounts for this ledger.
func (*Ledger) GenesisHash ¶
GenesisHash returns the genesis hash for this ledger.
func (*Ledger) GenesisProto ¶
func (l *Ledger) GenesisProto() config.ConsensusParams
GenesisProto returns the initial protocol for this ledger.
func (*Ledger) GetCatchpointCatchupState ¶
func (l *Ledger) GetCatchpointCatchupState(ctx context.Context) (state CatchpointCatchupState, err error)
GetCatchpointCatchupState returns the current state of the catchpoint catchup. GetCatchpointCatchupState는 catchpoint catchup의 현재 상태를 반환합니다.
func (*Ledger) GetCatchpointStream ¶
func (l *Ledger) GetCatchpointStream(round basics.Round) (ReadCloseSizer, error)
GetCatchpointStream returns a ReadCloseSizer file stream from which the catchpoint file for the provided round could be retrieved. If no such stream can be generated, a non-nil error is returned. The io.ReadCloser and the error are mutually exclusive - if error is returned, the file stream is guaranteed to be nil, and vice versa, if the file stream is not nil, the error is guaranteed to be nil.
func (*Ledger) GetCreator ¶
func (l *Ledger) GetCreator(cidx basics.CreatableIndex, ctype basics.CreatableType) (basics.Address, bool, error)
GetCreator is like GetCreatorForRound, but for the latest round and race-free with respect to ledger.Latest()
func (*Ledger) GetCreatorForRound ¶
func (l *Ledger) GetCreatorForRound(rnd basics.Round, cidx basics.CreatableIndex, ctype basics.CreatableType) (creator basics.Address, ok bool, err error)
GetCreatorForRound takes a CreatableIndex and a CreatableType and tries to look up a creator address, setting ok to false if the query succeeded but no creator was found.
func (*Ledger) GetLastCatchpointLabel ¶
GetLastCatchpointLabel returns the latest catchpoint label that was written to the database.
func (*Ledger) GetLedgerRootDir ¶
func (*Ledger) GetTrackerDbs ¶
Ledger가 가지고 있는 트래커 db 반환
func (*Ledger) IsWritingCatchpointFile ¶
IsWritingCatchpointFile returns true when a catchpoint file is being generated. The function is used by the catchup service to avoid memory pressure until the catchpoint file writing is complete.
func (*Ledger) LatestCommitted ¶
LatestCommitted returns the last block round number written to persistent storage. This block, and all previous blocks, are guaranteed to be available after a crash. In addition, it returns the latest block round number added to the ledger ( which will be flushed to persistent storage later on )
func (*Ledger) LatestTotals ¶
func (l *Ledger) LatestTotals() (basics.Round, ledgercore.AccountTotals, error)
LatestTotals returns the totals of all accounts for the most recent round, as well as the round number.
LatestTotals은 가장 최신라운드와 그 라운드에 있는 모든 계정이 가지고 있는 알고양을 반환(온라인, 오프라인, 참여안하는 계정별로 나눠서)
func (*Ledger) ListApplications ¶
func (l *Ledger) ListApplications(maxAppIdx basics.AppIndex, maxResults uint64) (results []basics.CreatableLocator, err error)
ListApplications takes a maximum app index and maximum result length, and returns up to that many CreatableLocators from the database where app idx is less than or equal to the maximum.
func (*Ledger) ListAssets ¶
func (l *Ledger) ListAssets(maxAssetIdx basics.AssetIndex, maxResults uint64) (results []basics.CreatableLocator, err error)
ListAssets takes a maximum asset index and maximum result length, and returns up to that many CreatableLocators from the database where app idx is less than or equal to the maximum.
func (*Ledger) Lookup ¶
Lookup uses the accounts tracker to return the account state for a given account in a particular round. The account values reflect the changes of all blocks up to and including rnd.
Lookup은 특정 라운드의 해당 계정의 상태를 반환하기 위해 accounts tracker를 사용 계정 값은 rnd를 포함한 이전 모든라운드의 변화를 반영한다.
func (*Ledger) LookupAgreement ¶
func (l *Ledger) LookupAgreement(rnd basics.Round, addr basics.Address) (basics.OnlineAccountData, error)
LookupAgreement returns account data used by agreement.
func (*Ledger) LookupWithoutRewards ¶
func (l *Ledger) LookupWithoutRewards(rnd basics.Round, addr basics.Address) (basics.AccountData, basics.Round, error)
LookupWithoutRewards is like Lookup but does not apply pending rewards up to the requested round rnd.
func (*Ledger) OnlineTotals ¶
OnlineTotals returns the online totals of all accounts at the end of round rnd.
func (*Ledger) RegisterBlockListeners ¶
func (l *Ledger) RegisterBlockListeners(listeners []BlockListener)
RegisterBlockListeners registers listeners that will be called when a new block is added to the ledger. RegisterBlockListeners 는 새 블록이 원장에 추가될 때 호출될 수신기를 등록합니다.
func (*Ledger) RegisterBlockTrackingListener ¶
func (l *Ledger) RegisterBlockTrackingListener(listener ValidateBlockListener)
func (*Ledger) SetLedgerRootDir ¶
func (*Ledger) StartEvaluator ¶
func (l *Ledger) StartEvaluator(hdr bookkeeping.BlockHeader, paysetHint, maxTxnBytesPerBlock int) (*internal.BlockEvaluator, error)
StartEvaluator creates a BlockEvaluator, given a ledger and a block header of the block that the caller is planning to evaluate. If the length of the payset being evaluated is known in advance, a paysetHint >= 0 can be passed, avoiding unnecessary payset slice growth. The optional maxTxnBytesPerBlock parameter provides a cap on the size of a single generated block size, when a non-zero value is passed. If a value of zero or less is passed to maxTxnBytesPerBlock, the consensus MaxTxnBytesPerBlock would be used instead.
func (*Ledger) Validate ¶
func (l *Ledger) Validate(ctx context.Context, blk bookkeeping.Block, executionPool execpool.BacklogPool) (*ledgercore.ValidatedBlock, error)
Validate uses the ledger to validate block blk as a candidate next block. It returns an error if blk is not the expected next block, or if blk is not a valid block (e.g., it has duplicate transactions, overspends some account, etc).
func (*Ledger) VerifiedTransactionCache ¶
func (l *Ledger) VerifiedTransactionCache() verify.VerifiedTransactionCache
VerifiedTransactionCache returns the verify.VerifiedTransactionCache
func (*Ledger) Wait ¶
Wait returns a channel that closes once a given round is stored durably in the ledger. When <-l.Wait(r) finishes, ledger is guaranteed to have round r, and will not lose round r after a crash. This makes it easy to use in a select{} statement.
func (*Ledger) WaitForCommit ¶
WaitForCommit waits until block r (and block before r) are durably written to disk.
type MerkleCommitter ¶
type MerkleCommitter struct {
// contains filtered or unexported fields
}
MerkleCommitter todo
func MakeMerkleCommitter ¶
func MakeMerkleCommitter(tx *sql.Tx, staging bool) (mc *MerkleCommitter, err error)
MakeMerkleCommitter creates a MerkleCommitter object that implements the merkletrie.Committer interface allowing storing and loading merkletrie pages from a sqlite database.
type MismatchingDatabaseRoundError ¶
type MismatchingDatabaseRoundError struct {
// contains filtered or unexported fields
}
MismatchingDatabaseRoundError is generated when we detect that the database round is different than the accountUpdates in-memory dbRound. This could happen normally when the database and the in-memory dbRound aren't synchronized. However, when we work in non-sync mode, we expect the database to be always synchronized with the in-memory data. When that condition is violated, this error is generated.
func (*MismatchingDatabaseRoundError) Error ¶
func (e *MismatchingDatabaseRoundError) Error() string
type ReadCloseSizer ¶
type ReadCloseSizer interface { io.ReadCloser Size() (int64, error) }
ReadCloseSizer interface implements the standard io.Reader and io.Closer as well as supporting the Size() function that let the caller know what the size of the stream would be (in bytes).
type RoundOffsetError ¶
type RoundOffsetError struct {
// contains filtered or unexported fields
}
RoundOffsetError is an error for when requested round is behind earliest stored db entry
func (*RoundOffsetError) Error ¶
func (e *RoundOffsetError) Error() string
type StaleDatabaseRoundError ¶
type StaleDatabaseRoundError struct {
// contains filtered or unexported fields
}
StaleDatabaseRoundError is generated when we detect that the database round is behind the accountUpdates in-memory dbRound. This should never happen, since we update the database first, and only upon a successful update we update the in-memory dbRound.
func (*StaleDatabaseRoundError) Error ¶
func (e *StaleDatabaseRoundError) Error() string
type ValidateBlockListener ¶
type ValidateBlockListener interface {
OnNewBlock2(block bookkeeping.Block, delta ledgercore.StateDelta)
}
Source Files
¶
- accountdb.go
- acctupdates.go
- blockdb.go
- blockqueue.go
- bulletin.go
- catchpointtracker.go
- catchpointwriter.go
- catchupaccessor.go
- evalindexer.go
- ledger.go
- lruaccts.go
- metrics.go
- msgp_gen.go
- notifier.go
- onlinetopheap.go
- persistedaccts_list.go
- roundlru.go
- stateDelta_tracker.go
- tracker.go
- trackerdb.go
- txtail.go
- voters.go