Documentation
¶
Index ¶
- Constants
- func NewAtomicTrieIterator(trieIterator *trie.Iterator, codec codec.Manager) *atomicTrieIterator
- type AtomicBackend
- func (a *AtomicBackend) AddBonusBlock(height uint64, blockID ids.ID)
- func (a *AtomicBackend) ApplyToSharedMemory(lastAcceptedBlock uint64) error
- func (a *AtomicBackend) AtomicTrie() *AtomicTrie
- func (a *AtomicBackend) GetVerifiedAtomicState(blockHash common.Hash) (*atomicState, error)
- func (a *AtomicBackend) InsertTxs(blockHash common.Hash, blockHeight uint64, parentHash common.Hash, ...) (common.Hash, error)
- func (a *AtomicBackend) IsBonus(blockHeight uint64, blockHash common.Hash) bool
- func (a *AtomicBackend) MarkApplyToSharedMemoryCursor(previousLastAcceptedHeight uint64) error
- func (a *AtomicBackend) SetLastAccepted(lastAcceptedHash common.Hash)
- type AtomicRepository
- func (a *AtomicRepository) GetByHeight(height uint64) ([]*atomic.Tx, error)
- func (a *AtomicRepository) GetByTxID(txID ids.ID) (*atomic.Tx, uint64, error)
- func (a *AtomicRepository) GetIndexHeight() (uint64, error)
- func (a *AtomicRepository) IterateByHeight(height uint64) database.Iterator
- func (a *AtomicRepository) Write(height uint64, txs []*atomic.Tx) error
- func (a *AtomicRepository) WriteBonus(height uint64, txs []*atomic.Tx) error
- type AtomicTrie
- func (a *AtomicTrie) AcceptTrie(height uint64, root common.Hash) (bool, error)
- func (a *AtomicTrie) Commit(height uint64, root common.Hash) error
- func (a *AtomicTrie) InsertTrie(nodes *trienode.NodeSet, root common.Hash) error
- func (a *AtomicTrie) Iterator(root common.Hash, cursor []byte) (*atomicTrieIterator, error)
- func (a *AtomicTrie) LastAcceptedRoot() common.Hash
- func (a *AtomicTrie) LastCommitted() (common.Hash, uint64)
- func (a *AtomicTrie) OpenTrie(root common.Hash) (*trie.Trie, error)
- func (a *AtomicTrie) RejectTrie(root common.Hash) error
- func (a *AtomicTrie) Root(height uint64) (common.Hash, error)
- func (a *AtomicTrie) TrieDB() *triedb.Database
- func (a *AtomicTrie) UpdateTrie(trie *trie.Trie, height uint64, atomicOps map[ids.ID]*avalancheatomic.Requests) error
Constants ¶
const (
TrieKeyLength = wrappers.LongLen + common.HashLength
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AtomicBackend ¶
type AtomicBackend struct {
// contains filtered or unexported fields
}
AtomicBackend provides an interface to the atomic trie and shared memory. the AtomicTrie, AtomicRepository, and the VM's shared memory.
func NewAtomicBackend ¶
func NewAtomicBackend( sharedMemory avalancheatomic.SharedMemory, bonusBlocks map[uint64]ids.ID, repo *AtomicRepository, lastAcceptedHeight uint64, lastAcceptedHash common.Hash, commitInterval uint64, ) (*AtomicBackend, error)
NewAtomicBackend creates an AtomicBackend from the specified dependencies
func (*AtomicBackend) AddBonusBlock ¶
func (a *AtomicBackend) AddBonusBlock(height uint64, blockID ids.ID)
AddBonusBlock adds a bonus block to the atomic backend
func (*AtomicBackend) ApplyToSharedMemory ¶
func (a *AtomicBackend) ApplyToSharedMemory(lastAcceptedBlock uint64) error
ApplyToSharedMemory applies the atomic operations that have been indexed into the trie but not yet applied to shared memory for heights less than or equal to [lastAcceptedBlock]. This executes operations in the range [cursorHeight+1, lastAcceptedBlock]. The cursor is initially set by MarkApplyToSharedMemoryCursor to signal to the atomic trie the range of operations that were added to the trie without being executed on shared memory.
func (*AtomicBackend) AtomicTrie ¶
func (a *AtomicBackend) AtomicTrie() *AtomicTrie
func (*AtomicBackend) GetVerifiedAtomicState ¶
func (a *AtomicBackend) GetVerifiedAtomicState(blockHash common.Hash) (*atomicState, error)
func (*AtomicBackend) InsertTxs ¶
func (a *AtomicBackend) InsertTxs(blockHash common.Hash, blockHeight uint64, parentHash common.Hash, txs []*atomic.Tx) (common.Hash, error)
InsertTxs calculates the root of the atomic trie that would result from applying [txs] to the atomic trie, starting at the state corresponding to previously verified block [parentHash]. If [blockHash] is provided, the modified atomic trie is pinned in memory and it's the caller's responsibility to call either Accept or Reject on the AtomicState which can be retreived from GetVerifiedAtomicState to commit the changes or abort them and free memory.
func (*AtomicBackend) IsBonus ¶
func (a *AtomicBackend) IsBonus(blockHeight uint64, blockHash common.Hash) bool
IsBonus returns true if the block for atomicState is a bonus block
func (*AtomicBackend) MarkApplyToSharedMemoryCursor ¶
func (a *AtomicBackend) MarkApplyToSharedMemoryCursor(previousLastAcceptedHeight uint64) error
MarkApplyToSharedMemoryCursor marks the atomic trie as containing atomic ops that have not been executed on shared memory starting at [previousLastAcceptedHeight+1]. This is used when state sync syncs the atomic trie, such that the atomic operations from [previousLastAcceptedHeight+1] to the [lastAcceptedHeight] set by state sync will not have been executed on shared memory.
func (*AtomicBackend) SetLastAccepted ¶
func (a *AtomicBackend) SetLastAccepted(lastAcceptedHash common.Hash)
SetLastAccepted is used after state-sync to update the last accepted block hash.
type AtomicRepository ¶
type AtomicRepository struct {
// contains filtered or unexported fields
}
AtomicRepository manages the database interactions for atomic operations.
func NewAtomicTxRepository ¶
func (*AtomicRepository) GetByHeight ¶
func (a *AtomicRepository) GetByHeight(height uint64) ([]*atomic.Tx, error)
GetByHeight returns all atomic txs processed on block at [height]. Returns [database.ErrNotFound] if there are no atomic transactions indexed at [height]. Note: if [height] is below the last accepted height, then this means that there were no atomic transactions in the block accepted at [height]. If [height] is greater than the last accepted height, then this will always return [database.ErrNotFound]
func (*AtomicRepository) GetByTxID ¶
GetByTxID queries [acceptedAtomicTxDB] for the [txID], parses a [*atomic.Tx] object if an entry is found, and returns it with the block height the atomic tx it represents was accepted on, along with an optional error.
func (*AtomicRepository) GetIndexHeight ¶
func (a *AtomicRepository) GetIndexHeight() (uint64, error)
GetIndexHeight returns the last height that was indexed by the atomic repository
func (*AtomicRepository) IterateByHeight ¶
func (a *AtomicRepository) IterateByHeight(height uint64) database.Iterator
IterateByHeight returns an iterator beginning at [height]. Note [height] must be greater than 0 since we assume there are no atomic txs in genesis.
func (*AtomicRepository) Write ¶
func (a *AtomicRepository) Write(height uint64, txs []*atomic.Tx) error
Write updates indexes maintained on atomic txs, so they can be queried by txID or height. This method must be called only once per height, and [txs] must include all atomic txs for the block accepted at the corresponding height.
func (*AtomicRepository) WriteBonus ¶
func (a *AtomicRepository) WriteBonus(height uint64, txs []*atomic.Tx) error
WriteBonus is similar to Write, except the [txID] => [height] is not overwritten if already exists.
type AtomicTrie ¶
type AtomicTrie struct {
// contains filtered or unexported fields
}
AtomicTrie is a trie that is used to store atomic operations.
func (*AtomicTrie) AcceptTrie ¶
AcceptTrie commits the triedb at [root] if needed and returns true if a commit was performed.
func (*AtomicTrie) Commit ¶
func (a *AtomicTrie) Commit(height uint64, root common.Hash) error
Commit calls Commit on the underlying trieDB and updates metadata pointers.
func (*AtomicTrie) InsertTrie ¶
func (*AtomicTrie) Iterator ¶
func (a *AtomicTrie) Iterator(root common.Hash, cursor []byte) (*atomicTrieIterator, error)
Iterator returns an [atomicTrieIterator] that iterates the trie from the given atomic trie root, starting at the specified [cursor].
func (*AtomicTrie) LastAcceptedRoot ¶
func (a *AtomicTrie) LastAcceptedRoot() common.Hash
func (*AtomicTrie) LastCommitted ¶
func (a *AtomicTrie) LastCommitted() (common.Hash, uint64)
LastCommitted returns the last committed trie hash and last committed height
func (*AtomicTrie) RejectTrie ¶
func (a *AtomicTrie) RejectTrie(root common.Hash) error
func (*AtomicTrie) Root ¶
func (a *AtomicTrie) Root(height uint64) (common.Hash, error)
Root returns hash if it exists at specified height if trie was not committed at provided height, it returns common.Hash{} instead
func (*AtomicTrie) TrieDB ¶
func (a *AtomicTrie) TrieDB() *triedb.Database
func (*AtomicTrie) UpdateTrie ¶
func (a *AtomicTrie) UpdateTrie(trie *trie.Trie, height uint64, atomicOps map[ids.ID]*avalancheatomic.Requests) error