Documentation ¶
Index ¶
- Variables
- type AcceptanceDataStore
- type BlockBuilder
- type BlockHeaderStore
- type BlockHeap
- type BlockIterator
- type BlockParentBuilder
- type BlockProcessor
- type BlockRelationStore
- type BlockRelations
- type BlockStatusStore
- type BlockStore
- type BlockValidator
- type BlocksWithTrustedDataDAAWindowStore
- type CoinbaseManager
- type ConsensusStateManager
- type ConsensusStateStore
- type DAABlocksStore
- type DAGTopologyManager
- type DAGTraversalManager
- type DBBucket
- type DBCursor
- type DBKey
- type DBManager
- type DBReader
- type DBTransaction
- type DBWriter
- type DifficultyManager
- type FinalityManager
- type FinalityStore
- type FutureCoveringTreeNodeSet
- type GHOSTDAGDataStore
- type GHOSTDAGManager
- type HeaderSelectedTipStore
- type HeadersSelectedChainStore
- type HeadersSelectedTipManager
- type MergeDepthManager
- type MergeDepthRootStore
- type Multiset
- type MultisetStore
- type MutableReachabilityData
- type ParentsManager
- type PastMedianTimeManager
- type PruningManager
- type PruningProofManager
- type PruningStore
- type ReachabilityData
- type ReachabilityDataStore
- type ReachabilityInterval
- type ReachabilityManager
- type StagingArea
- type StagingShard
- type StagingShardID
- type Store
- type SubDAG
- type SubDAGBlock
- type SyncManager
- type TransactionValidator
- type UTXODiffReversalData
- type UTXODiffStore
- type WindowHeapSliceStore
Constants ¶
This section is empty.
Variables ¶
var ErrBlockNotInSelectedParentChain = errors.New("Block is not in selected parent chain")
ErrBlockNotInSelectedParentChain is returned from CreateHeadersSelectedChainBlockLocator if one of the parameters passed to it are not in the headers selected parent chain
var ErrReachedMaxTraversalAllowed = errors.New("Traversal searching for anticone passed the maxTraversalAllowed limit")
ErrReachedMaxTraversalAllowed is returned from AnticoneFromBlocks if `maxTraversalAllowed` was specified and the traversal passed it
var VirtualBlockHash = externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
})
VirtualBlockHash is a marker hash for the virtual block
var VirtualGenesisBlockHash = externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
})
VirtualGenesisBlockHash is a marker hash for the virtual genesis block
Functions ¶
This section is empty.
Types ¶
type AcceptanceDataStore ¶
type AcceptanceDataStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, acceptanceData externalapi.AcceptanceData) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (externalapi.AcceptanceData, error) Delete(stagingArea *StagingArea, blockHash *externalapi.DomainHash) }
AcceptanceDataStore represents a store of AcceptanceData
type BlockBuilder ¶
type BlockBuilder interface { BuildBlock(coinbaseData *externalapi.DomainCoinbaseData, transactions []*externalapi.DomainTransaction) (block *externalapi.DomainBlock, coinbaseHasRedReward bool, err error) }
BlockBuilder is responsible for creating blocks from the current state
type BlockHeaderStore ¶
type BlockHeaderStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, blockHeader externalapi.BlockHeader) IsStaged(stagingArea *StagingArea) bool BlockHeader(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (externalapi.BlockHeader, error) HasBlockHeader(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) BlockHeaders(dbContext DBReader, stagingArea *StagingArea, blockHashes []*externalapi.DomainHash) ([]externalapi.BlockHeader, error) Delete(stagingArea *StagingArea, blockHash *externalapi.DomainHash) Count(stagingArea *StagingArea) uint64 }
BlockHeaderStore represents a store of block headers
type BlockHeap ¶
type BlockHeap interface { Push(blockHash *externalapi.DomainHash) error PushSlice(blockHash []*externalapi.DomainHash) error Pop() *externalapi.DomainHash Len() int ToSlice() []*externalapi.DomainHash }
BlockHeap represents a heap of block hashes, providing a priority-queue functionality
type BlockIterator ¶
type BlockIterator interface { First() bool Next() bool Get() (*externalapi.DomainHash, error) Close() error }
BlockIterator is an iterator over blocks according to some order.
type BlockParentBuilder ¶
type BlockParentBuilder interface { BuildParents(stagingArea *StagingArea, daaScore uint64, directParentHashes []*externalapi.DomainHash) ([]externalapi.BlockLevelParents, error) }
BlockParentBuilder exposes a method to build super-block parents for a given set of direct parents
type BlockProcessor ¶
type BlockProcessor interface { ValidateAndInsertBlock(block *externalapi.DomainBlock, shouldValidateAgainstUTXO bool) (*externalapi.VirtualChangeSet, externalapi.BlockStatus, error) ValidateAndInsertImportedPruningPoint(newPruningPoint *externalapi.DomainHash) error ValidateAndInsertBlockWithTrustedData(block *externalapi.BlockWithTrustedData, validateUTXO bool) (*externalapi.VirtualChangeSet, externalapi.BlockStatus, error) }
BlockProcessor is responsible for processing incoming blocks
type BlockRelationStore ¶
type BlockRelationStore interface { Store StageBlockRelation(stagingArea *StagingArea, blockHash *externalapi.DomainHash, blockRelations *BlockRelations) IsStaged(stagingArea *StagingArea) bool BlockRelation(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*BlockRelations, error) Has(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) UnstageAll(stagingArea *StagingArea) }
BlockRelationStore represents a store of BlockRelations
type BlockRelations ¶
type BlockRelations struct { Parents []*externalapi.DomainHash Children []*externalapi.DomainHash }
BlockRelations represents a block's parent/child relations
func (*BlockRelations) Clone ¶
func (br *BlockRelations) Clone() *BlockRelations
Clone returns a clone of BlockRelations
func (*BlockRelations) Equal ¶
func (br *BlockRelations) Equal(other *BlockRelations) bool
Equal returns whether br equals to other
type BlockStatusStore ¶
type BlockStatusStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, blockStatus externalapi.BlockStatus) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (externalapi.BlockStatus, error) Exists(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) }
BlockStatusStore represents a store of BlockStatuses
type BlockStore ¶
type BlockStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, block *externalapi.DomainBlock) IsStaged(stagingArea *StagingArea) bool Block(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) HasBlock(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) Blocks(dbContext DBReader, stagingArea *StagingArea, blockHashes []*externalapi.DomainHash) ([]*externalapi.DomainBlock, error) Delete(stagingArea *StagingArea, blockHash *externalapi.DomainHash) Count(stagingArea *StagingArea) uint64 AllBlockHashesIterator(dbContext DBReader) (BlockIterator, error) }
BlockStore represents a store of blocks
type BlockValidator ¶
type BlockValidator interface { ValidateHeaderInIsolation(stagingArea *StagingArea, blockHash *externalapi.DomainHash) error ValidateBodyInIsolation(stagingArea *StagingArea, blockHash *externalapi.DomainHash) error ValidateHeaderInContext(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) error ValidateBodyInContext(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) error ValidatePruningPointViolationAndProofOfWorkAndDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) error }
BlockValidator exposes a set of validation classes, after which it's possible to determine whether a block is valid
type BlocksWithTrustedDataDAAWindowStore ¶
type BlocksWithTrustedDataDAAWindowStore interface { Store IsStaged(stagingArea *StagingArea) bool Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, index uint64, ghostdagData *externalapi.BlockGHOSTDAGDataHashPair) DAAWindowBlock(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash, index uint64) (*externalapi.BlockGHOSTDAGDataHashPair, error) }
BlocksWithTrustedDataDAAWindowStore stores the DAA window of blocks with trusted data
type CoinbaseManager ¶
type CoinbaseManager interface { ExpectedCoinbaseTransaction(stagingArea *StagingArea, blockHash *externalapi.DomainHash, coinbaseData *externalapi.DomainCoinbaseData) (expectedTransaction *externalapi.DomainTransaction, hasRedReward bool, err error) CalcBlockSubsidy(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint64, error) ExtractCoinbaseDataBlueScoreAndSubsidy(coinbaseTx *externalapi.DomainTransaction) (blueScore uint64, coinbaseData *externalapi.DomainCoinbaseData, subsidy uint64, err error) }
CoinbaseManager exposes methods for handling blocks' coinbase transactions
type ConsensusStateManager ¶
type ConsensusStateManager interface { AddBlock(stagingArea *StagingArea, blockHash *externalapi.DomainHash, updateVirtual bool) (*externalapi.SelectedChainPath, externalapi.UTXODiff, *UTXODiffReversalData, error) PopulateTransactionWithUTXOEntries(stagingArea *StagingArea, transaction *externalapi.DomainTransaction) error ImportPruningPointUTXOSet(stagingArea *StagingArea, newPruningPoint *externalapi.DomainHash) error ImportPruningPoints(stagingArea *StagingArea, pruningPoints []externalapi.BlockHeader) error RestorePastUTXOSetIterator(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (externalapi.ReadOnlyUTXOSetIterator, error) CalculatePastUTXOAndAcceptanceData(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (externalapi.UTXODiff, externalapi.AcceptanceData, Multiset, error) GetVirtualSelectedParentChainFromBlock(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.SelectedChainPath, error) RecoverUTXOIfRequired() error ReverseUTXODiffs(tipHash *externalapi.DomainHash, reversalData *UTXODiffReversalData) error ResolveVirtual(maxBlocksToResolve uint64) (*externalapi.VirtualChangeSet, bool, error) }
ConsensusStateManager manages the node's consensus state
type ConsensusStateStore ¶
type ConsensusStateStore interface { Store IsStaged(stagingArea *StagingArea) bool StageVirtualUTXODiff(stagingArea *StagingArea, virtualUTXODiff externalapi.UTXODiff) UTXOByOutpoint(dbContext DBReader, stagingArea *StagingArea, outpoint *externalapi.DomainOutpoint) (externalapi.UTXOEntry, error) HasUTXOByOutpoint(dbContext DBReader, stagingArea *StagingArea, outpoint *externalapi.DomainOutpoint) (bool, error) VirtualUTXOSetIterator(dbContext DBReader, stagingArea *StagingArea) (externalapi.ReadOnlyUTXOSetIterator, error) VirtualUTXOs(dbContext DBReader, fromOutpoint *externalapi.DomainOutpoint, limit int) ([]*externalapi.OutpointAndUTXOEntryPair, error) StageTips(stagingArea *StagingArea, tipHashes []*externalapi.DomainHash) Tips(stagingArea *StagingArea, dbContext DBReader) ([]*externalapi.DomainHash, error) StartImportingPruningPointUTXOSet(dbContext DBWriter) error HadStartedImportingPruningPointUTXOSet(dbContext DBWriter) (bool, error) ImportPruningPointUTXOSetIntoVirtualUTXOSet(dbContext DBWriter, pruningPointUTXOSetIterator externalapi.ReadOnlyUTXOSetIterator) error FinishImportingPruningPointUTXOSet(dbContext DBWriter) error }
ConsensusStateStore represents a store for the current consensus state
type DAABlocksStore ¶
type DAABlocksStore interface { Store StageDAAScore(stagingArea *StagingArea, blockHash *externalapi.DomainHash, daaScore uint64) StageBlockDAAAddedBlocks(stagingArea *StagingArea, blockHash *externalapi.DomainHash, addedBlocks []*externalapi.DomainHash) IsStaged(stagingArea *StagingArea) bool DAAAddedBlocks(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) DAAScore(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint64, error) Delete(stagingArea *StagingArea, blockHash *externalapi.DomainHash) }
DAABlocksStore represents a store of ???
type DAGTopologyManager ¶
type DAGTopologyManager interface { Parents(stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) Children(stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) IsParentOf(stagingArea *StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) IsChildOf(stagingArea *StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) IsAncestorOf(stagingArea *StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) IsAncestorOfAny(stagingArea *StagingArea, blockHash *externalapi.DomainHash, potentialDescendants []*externalapi.DomainHash) (bool, error) IsAnyAncestorOf(stagingArea *StagingArea, potentialAncestors []*externalapi.DomainHash, blockHash *externalapi.DomainHash) (bool, error) IsInSelectedParentChainOf(stagingArea *StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) ChildInSelectedParentChainOf(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash) (*externalapi.DomainHash, error) SetParents(stagingArea *StagingArea, blockHash *externalapi.DomainHash, parentHashes []*externalapi.DomainHash) error }
DAGTopologyManager exposes methods for querying relationships between blocks in the DAG
type DAGTraversalManager ¶
type DAGTraversalManager interface { LowestChainBlockAboveOrEqualToBlueScore(stagingArea *StagingArea, highHash *externalapi.DomainHash, blueScore uint64) (*externalapi.DomainHash, error) // SelectedChildIterator should return a BlockIterator that iterates // from lowHash (exclusive) to highHash (inclusive) over highHash's selected parent chain SelectedChildIterator(stagingArea *StagingArea, highHash, lowHash *externalapi.DomainHash, includeLowHash bool) (BlockIterator, error) SelectedChild(stagingArea *StagingArea, highHash, lowHash *externalapi.DomainHash) (*externalapi.DomainHash, error) AnticoneFromBlocks(stagingArea *StagingArea, tips []*externalapi.DomainHash, blockHash *externalapi.DomainHash, maxTraversalAllowed uint64) ([]*externalapi.DomainHash, error) AnticoneFromVirtualPOV(stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) BlockWindow(stagingArea *StagingArea, highHash *externalapi.DomainHash, windowSize int) ([]*externalapi.DomainHash, error) DAABlockWindow(stagingArea *StagingArea, highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) NewDownHeap(stagingArea *StagingArea) BlockHeap NewUpHeap(stagingArea *StagingArea) BlockHeap CalculateChainPath(stagingArea *StagingArea, fromBlockHash, toBlockHash *externalapi.DomainHash) ( *externalapi.SelectedChainPath, error) }
DAGTraversalManager exposes methods for traversing blocks in the DAG
type DBBucket ¶
type DBBucket interface { Bucket(bucketBytes []byte) DBBucket Key(suffix []byte) DBKey Path() []byte }
DBBucket is an interface for a database bucket
type DBCursor ¶
type DBCursor interface { // Next moves the iterator to the next key/value pair. It returns whether the // iterator is exhausted. Panics if the cursor is closed. Next() bool // First moves the iterator to the first key/value pair. It returns false if // such a pair does not exist. Panics if the cursor is closed. First() bool // Seek moves the iterator to the first key/value pair whose key is greater // than or equal to the given key. It returns ErrNotFound if such pair does not // exist. Seek(key DBKey) error // Key returns the key of the current key/value pair, or ErrNotFound if done. // The caller should not modify the contents of the returned key, and // its contents may change on the next call to Next. Key() (DBKey, error) // Value returns the value of the current key/value pair, or ErrNotFound if done. // The caller should not modify the contents of the returned slice, and its // contents may change on the next call to Next. Value() ([]byte, error) // Close releases associated resources. Close() error }
DBCursor iterates over database entries given some bucket.
type DBManager ¶
type DBManager interface { DBWriter // Begin begins a new database transaction. Begin() (DBTransaction, error) }
DBManager defines the interface of a database that can begin transactions and read data.
type DBReader ¶
type DBReader interface { // Get gets the value for the given key. It returns // ErrNotFound if the given key does not exist. Get(key DBKey) ([]byte, error) // Has returns true if the database does contains the // given key. Has(key DBKey) (bool, error) // Cursor begins a new cursor over the given bucket. Cursor(bucket DBBucket) (DBCursor, error) }
DBReader defines a proxy over domain data access
type DBTransaction ¶
type DBTransaction interface { DBWriter // Rollback rolls back whatever changes were made to the // database within this transaction. Rollback() error // Commit commits whatever changes were made to the database // within this transaction. Commit() error // RollbackUnlessClosed rolls back changes that were made to // the database within the transaction, unless the transaction // had already been closed using either Rollback or Commit. RollbackUnlessClosed() error }
DBTransaction is a proxy over domain data access that requires an open database transaction
type DBWriter ¶
type DBWriter interface { DBReader // Put sets the value for the given key. It overwrites // any previous value for that key. Put(key DBKey, value []byte) error // Delete deletes the value for the given key. Will not // return an error if the key doesn't exist. Delete(key DBKey) error }
DBWriter is an interface to write to the database
type DifficultyManager ¶
type DifficultyManager interface { StageDAADataAndReturnRequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) (uint32, error) RequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, error) EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) }
DifficultyManager provides a method to resolve the difficulty value of a block
type FinalityManager ¶
type FinalityManager interface { VirtualFinalityPoint(stagingArea *StagingArea) (*externalapi.DomainHash, error) FinalityPoint(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) (*externalapi.DomainHash, error) }
FinalityManager provides method to validate that a block does not violate finality
type FinalityStore ¶
type FinalityStore interface { Store IsStaged(stagingArea *StagingArea) bool StageFinalityPoint(stagingArea *StagingArea, blockHash *externalapi.DomainHash, finalityPointHash *externalapi.DomainHash) FinalityPoint(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) }
FinalityStore represents a store for finality data
type FutureCoveringTreeNodeSet ¶
type FutureCoveringTreeNodeSet []*externalapi.DomainHash
FutureCoveringTreeNodeSet represents a collection of blocks in the future of a certain block. Once a block B is added to the DAG, every block A_i in B's selected parent anticone must register B in its FutureCoveringTreeNodeSet. This allows to relatively quickly (O(log(|FutureCoveringTreeNodeSet|))) query whether B is a descendent (is in the "future") of any block that previously registered it.
Note that FutureCoveringTreeNodeSet is meant to be queried only if B is not a reachability tree descendant of the block in question, as reachability tree queries are always O(1).
See insertNode, hasAncestorOf, and isInPast for further details.
func (FutureCoveringTreeNodeSet) Clone ¶
func (fctns FutureCoveringTreeNodeSet) Clone() FutureCoveringTreeNodeSet
Clone returns a clone of FutureCoveringTreeNodeSet
func (FutureCoveringTreeNodeSet) Equal ¶
func (fctns FutureCoveringTreeNodeSet) Equal(other FutureCoveringTreeNodeSet) bool
Equal returns whether fctns equals to other
type GHOSTDAGDataStore ¶
type GHOSTDAGDataStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, blockGHOSTDAGData *externalapi.BlockGHOSTDAGData, isTrustedData bool) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash, isTrustedData bool) (*externalapi.BlockGHOSTDAGData, error) UnstageAll(stagingArea *StagingArea) }
GHOSTDAGDataStore represents a store of BlockGHOSTDAGData
type GHOSTDAGManager ¶
type GHOSTDAGManager interface { GHOSTDAG(stagingArea *StagingArea, blockHash *externalapi.DomainHash) error ChooseSelectedParent(stagingArea *StagingArea, blockHashes ...*externalapi.DomainHash) (*externalapi.DomainHash, error) Less(blockHashA *externalapi.DomainHash, ghostdagDataA *externalapi.BlockGHOSTDAGData, blockHashB *externalapi.DomainHash, ghostdagDataB *externalapi.BlockGHOSTDAGData) bool GetSortedMergeSet(stagingArea *StagingArea, current *externalapi.DomainHash) ([]*externalapi.DomainHash, error) }
GHOSTDAGManager resolves and manages GHOSTDAG block data
type HeaderSelectedTipStore ¶
type HeaderSelectedTipStore interface { Store Stage(stagingArea *StagingArea, selectedTip *externalapi.DomainHash) IsStaged(stagingArea *StagingArea) bool HeadersSelectedTip(dbContext DBReader, stagingArea *StagingArea) (*externalapi.DomainHash, error) Has(dbContext DBReader, stagingArea *StagingArea) (bool, error) }
HeaderSelectedTipStore represents a store of the headers selected tip
type HeadersSelectedChainStore ¶
type HeadersSelectedChainStore interface { Store Stage(dbContext DBReader, stagingArea *StagingArea, chainChanges *externalapi.SelectedChainPath) error IsStaged(stagingArea *StagingArea) bool GetIndexByHash(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint64, error) GetHashByIndex(dbContext DBReader, stagingArea *StagingArea, index uint64) (*externalapi.DomainHash, error) }
HeadersSelectedChainStore represents a store of the headers selected chain
type HeadersSelectedTipManager ¶
type HeadersSelectedTipManager interface {
AddHeaderTip(stagingArea *StagingArea, hash *externalapi.DomainHash) error
}
HeadersSelectedTipManager manages the state of the headers selected tip
type MergeDepthManager ¶
type MergeDepthManager interface { CheckBoundedMergeDepth(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) error NonBoundedMergeDepthViolatingBlues(stagingArea *StagingArea, blockHash, mergeDepthRoot *externalapi.DomainHash) ([]*externalapi.DomainHash, error) VirtualMergeDepthRoot(stagingArea *StagingArea) (*externalapi.DomainHash, error) }
MergeDepthManager is used to validate mergeDepth for blocks
type MergeDepthRootStore ¶
type MergeDepthRootStore interface { Store IsStaged(stagingArea *StagingArea) bool StageMergeDepthRoot(stagingArea *StagingArea, blockHash *externalapi.DomainHash, root *externalapi.DomainHash) MergeDepthRoot(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) }
MergeDepthRootStore represents a store for merge depth roots
type Multiset ¶
type Multiset interface { Add(data []byte) Remove(data []byte) Hash() *externalapi.DomainHash Serialize() []byte Clone() Multiset }
Multiset represents a secp256k1 multiset
type MultisetStore ¶
type MultisetStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, multiset Multiset) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (Multiset, error) Delete(stagingArea *StagingArea, blockHash *externalapi.DomainHash) }
MultisetStore represents a store of Multisets
type MutableReachabilityData ¶
type MutableReachabilityData interface { ReachabilityData AddChild(child *externalapi.DomainHash) SetParent(parent *externalapi.DomainHash) SetInterval(interval *ReachabilityInterval) SetFutureCoveringSet(futureCoveringSet FutureCoveringTreeNodeSet) }
MutableReachabilityData represents a block's MutableReachabilityData, with ability to edit it
type ParentsManager ¶
type ParentsManager interface { ParentsAtLevel(blockHeader externalapi.BlockHeader, level int) externalapi.BlockLevelParents Parents(blockHeader externalapi.BlockHeader) []externalapi.BlockLevelParents }
ParentsManager lets is a wrapper above header parents that replaces empty parents with genesis when needed.
type PastMedianTimeManager ¶
type PastMedianTimeManager interface { PastMedianTime(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (int64, error) InvalidateVirtualPastMedianTimeCache() }
PastMedianTimeManager provides a method to resolve the past median time of a block
type PruningManager ¶
type PruningManager interface { UpdatePruningPointByVirtual(stagingArea *StagingArea) error IsValidPruningPoint(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) ArePruningPointsViolatingFinality(stagingArea *StagingArea, pruningPoints []externalapi.BlockHeader) (bool, error) ArePruningPointsInValidChain(stagingArea *StagingArea) (bool, error) ClearImportedPruningPointData() error AppendImportedPruningPointUTXOs(outpointAndUTXOEntryPairs []*externalapi.OutpointAndUTXOEntryPair) error UpdatePruningPointIfRequired() error PruneAllBlocksBelow(stagingArea *StagingArea, pruningPointHash *externalapi.DomainHash) error PruningPointAndItsAnticone() ([]*externalapi.DomainHash, error) ExpectedHeaderPruningPoint(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) TrustedBlockAssociatedGHOSTDAGDataBlockHashes(stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) }
PruningManager resolves and manages the current pruning point
type PruningProofManager ¶
type PruningProofManager interface { BuildPruningPointProof(stagingArea *StagingArea) (*externalapi.PruningPointProof, error) ValidatePruningPointProof(pruningPointProof *externalapi.PruningPointProof) error ApplyPruningPointProof(pruningPointProof *externalapi.PruningPointProof) error }
PruningProofManager builds, validates and applies pruning proofs.
type PruningStore ¶
type PruningStore interface { Store StagePruningPoint(dbContext DBWriter, stagingArea *StagingArea, pruningPointBlockHash *externalapi.DomainHash) error StagePruningPointByIndex(dbContext DBReader, stagingArea *StagingArea, pruningPointBlockHash *externalapi.DomainHash, index uint64) error StagePruningPointCandidate(stagingArea *StagingArea, candidate *externalapi.DomainHash) IsStaged(stagingArea *StagingArea) bool PruningPointCandidate(dbContext DBReader, stagingArea *StagingArea) (*externalapi.DomainHash, error) HasPruningPointCandidate(dbContext DBReader, stagingArea *StagingArea) (bool, error) PruningPoint(dbContext DBReader, stagingArea *StagingArea) (*externalapi.DomainHash, error) HasPruningPoint(dbContext DBReader, stagingArea *StagingArea) (bool, error) CurrentPruningPointIndex(dbContext DBReader, stagingArea *StagingArea) (uint64, error) PruningPointByIndex(dbContext DBReader, stagingArea *StagingArea, index uint64) (*externalapi.DomainHash, error) StageStartUpdatingPruningPointUTXOSet(stagingArea *StagingArea) HadStartedUpdatingPruningPointUTXOSet(dbContext DBWriter) (bool, error) FinishUpdatingPruningPointUTXOSet(dbContext DBWriter) error UpdatePruningPointUTXOSet(dbContext DBWriter, diff externalapi.UTXODiff) error ClearImportedPruningPointUTXOs(dbContext DBWriter) error AppendImportedPruningPointUTXOs(dbTx DBTransaction, outpointAndUTXOEntryPairs []*externalapi.OutpointAndUTXOEntryPair) error ImportedPruningPointUTXOIterator(dbContext DBReader) (externalapi.ReadOnlyUTXOSetIterator, error) ClearImportedPruningPointMultiset(dbContext DBWriter) error ImportedPruningPointMultiset(dbContext DBReader) (Multiset, error) UpdateImportedPruningPointMultiset(dbTx DBTransaction, multiset Multiset) error CommitImportedPruningPointUTXOSet(dbContext DBWriter) error PruningPointUTXOs(dbContext DBReader, fromOutpoint *externalapi.DomainOutpoint, limit int) ([]*externalapi.OutpointAndUTXOEntryPair, error) PruningPointUTXOIterator(dbContext DBReader) (externalapi.ReadOnlyUTXOSetIterator, error) }
PruningStore represents a store for the current pruning state
type ReachabilityData ¶
type ReachabilityData interface { Children() []*externalapi.DomainHash Parent() *externalapi.DomainHash Interval() *ReachabilityInterval FutureCoveringSet() FutureCoveringTreeNodeSet CloneMutable() MutableReachabilityData Equal(other ReachabilityData) bool }
ReachabilityData is a read-only version of a block's MutableReachabilityData Use CloneWritable to edit the MutableReachabilityData.
type ReachabilityDataStore ¶
type ReachabilityDataStore interface { Store StageReachabilityData(stagingArea *StagingArea, blockHash *externalapi.DomainHash, reachabilityData ReachabilityData) StageReachabilityReindexRoot(stagingArea *StagingArea, reachabilityReindexRoot *externalapi.DomainHash) IsStaged(stagingArea *StagingArea) bool ReachabilityData(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (ReachabilityData, error) HasReachabilityData(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) ReachabilityReindexRoot(dbContext DBReader, stagingArea *StagingArea) (*externalapi.DomainHash, error) Delete(dbContext DBWriter) error }
ReachabilityDataStore represents a store of ReachabilityData
type ReachabilityInterval ¶
ReachabilityInterval represents an interval to be used within the tree reachability algorithm. See ReachabilityTreeNode for further details.
func (*ReachabilityInterval) Clone ¶
func (ri *ReachabilityInterval) Clone() *ReachabilityInterval
Clone returns a clone of ReachabilityInterval
func (*ReachabilityInterval) Equal ¶
func (ri *ReachabilityInterval) Equal(other *ReachabilityInterval) bool
Equal returns whether ri equals to other
func (*ReachabilityInterval) String ¶
func (ri *ReachabilityInterval) String() string
type ReachabilityManager ¶
type ReachabilityManager interface { Init(stagingArea *StagingArea) error AddBlock(stagingArea *StagingArea, blockHash *externalapi.DomainHash) error IsReachabilityTreeAncestorOf(stagingArea *StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) IsDAGAncestorOf(stagingArea *StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) UpdateReindexRoot(stagingArea *StagingArea, selectedTip *externalapi.DomainHash) error FindNextAncestor(stagingArea *StagingArea, descendant, ancestor *externalapi.DomainHash) (*externalapi.DomainHash, error) }
ReachabilityManager maintains a structure that allows to answer reachability queries in sub-linear time
type StagingArea ¶
type StagingArea struct {
// contains filtered or unexported fields
}
StagingArea is single changeset inside the consensus database, similar to a transaction in a classic database. Each StagingArea consists of multiple StagingShards, one for each dataStore that has any changes within it. To enable maximum flexibility for all stores, each has to define it's own Commit method, and pass it to the StagingArea through the relevant StagingShard.
When the StagingArea is being Committed, it goes over all it's shards, and commits those one-by-one. Since Commit happens in a DatabaseTransaction, a StagingArea is atomic.
func NewStagingArea ¶
func NewStagingArea() *StagingArea
NewStagingArea creates a new, empty staging area.
func (*StagingArea) Commit ¶
func (sa *StagingArea) Commit(dbTx DBTransaction) error
Commit goes over all the Shards in the StagingArea and commits them, inside the provided database transaction. Note: the transaction itself is not committed, this is the callers responsibility to commit it.
func (*StagingArea) GetOrCreateShard ¶
func (sa *StagingArea) GetOrCreateShard(shardID StagingShardID, createFunc func() StagingShard) StagingShard
GetOrCreateShard attempts to retrieve a shard with the given name. If it does not exist - a new shard is created using `createFunc`.
type StagingShard ¶
type StagingShard interface {
Commit(dbTx DBTransaction) error
}
StagingShard is an interface that enables every store to have it's own Commit logic See StagingArea for more details
type StagingShardID ¶
type StagingShardID uint64
StagingShardID is used to identify each of the store's staging shards
type SubDAG ¶
type SubDAG struct { RootHashes []*externalapi.DomainHash TipHashes []*externalapi.DomainHash Blocks map[externalapi.DomainHash]*SubDAGBlock }
SubDAG represents a context-free representation of a partial DAG
type SubDAGBlock ¶
type SubDAGBlock struct { BlockHash *externalapi.DomainHash ParentHashes []*externalapi.DomainHash ChildHashes []*externalapi.DomainHash }
SubDAGBlock represents a block in a SubDAG
type SyncManager ¶
type SyncManager interface { GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) ( hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) GetAnticone(stagingArea *StagingArea, blockHash, contextHash *externalapi.DomainHash, maxBlocks uint64) (hashes []*externalapi.DomainHash, err error) GetMissingBlockBodyHashes(stagingArea *StagingArea, highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) CreateBlockLocator(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, limit uint32) ( externalapi.BlockLocator, error) CreateHeadersSelectedChainBlockLocator(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash) ( externalapi.BlockLocator, error) GetSyncInfo(stagingArea *StagingArea) (*externalapi.SyncInfo, error) }
SyncManager exposes functions to support sync between htnd nodes
type TransactionValidator ¶
type TransactionValidator interface { ValidateTransactionInIsolation(transaction *externalapi.DomainTransaction, povDAAScore uint64) error ValidateTransactionInContextIgnoringUTXO(stagingArea *StagingArea, tx *externalapi.DomainTransaction, povBlockHash *externalapi.DomainHash, povBlockPastMedianTime int64) error ValidateTransactionInContextAndPopulateFee(stagingArea *StagingArea, tx *externalapi.DomainTransaction, povBlockHash *externalapi.DomainHash) error PopulateMass(transaction *externalapi.DomainTransaction) }
TransactionValidator exposes a set of validation classes, after which it's possible to determine whether a transaction is valid
type UTXODiffReversalData ¶
type UTXODiffReversalData struct { SelectedParentHash *externalapi.DomainHash SelectedParentUTXODiff externalapi.UTXODiff }
UTXODiffReversalData is used by ConsensusStateManager to reverse the UTXODiffs during a re-org
type UTXODiffStore ¶
type UTXODiffStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, utxoDiff externalapi.UTXODiff, utxoDiffChild *externalapi.DomainHash) IsStaged(stagingArea *StagingArea) bool UTXODiff(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (externalapi.UTXODiff, error) UTXODiffChild(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.DomainHash, error) HasUTXODiffChild(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (bool, error) Delete(stagingArea *StagingArea, blockHash *externalapi.DomainHash) }
UTXODiffStore represents a store of UTXODiffs
type WindowHeapSliceStore ¶
type WindowHeapSliceStore interface { Store Stage(stagingArea *StagingArea, blockHash *externalapi.DomainHash, windowSize int, pairs []*externalapi.BlockGHOSTDAGDataHashPair) IsStaged(stagingArea *StagingArea) bool Get(stagingArea *StagingArea, blockHash *externalapi.DomainHash, windowSize int) ([]*externalapi.BlockGHOSTDAGDataHashPair, error) }
WindowHeapSliceStore caches the slices that are needed for the heap implementation of DAGTraversalManager.BlockWindow
Source Files ¶
- block_heap.go
- blockiterator.go
- blockrelations.go
- database.go
- errors.go
- interface_datastructures_acceptancedatastore.go
- interface_datastructures_blockheaderstore.go
- interface_datastructures_blockrelationstore.go
- interface_datastructures_blocks_with_trusted_data_daa_window_store.go
- interface_datastructures_blockstatusstore.go
- interface_datastructures_blockstore.go
- interface_datastructures_consensusstatestore.go
- interface_datastructures_daablocksstore.go
- interface_datastructures_finalitystore.go
- interface_datastructures_ghostdagdatastore.go
- interface_datastructures_headersselectedchainstore.go
- interface_datastructures_headertipsstore.go
- interface_datastructures_mergedepthrootstore.go
- interface_datastructures_multisetstore.go
- interface_datastructures_pruningstore.go
- interface_datastructures_reachabilitydatastore.go
- interface_datastructures_utxodiffstore.go
- interface_datastructures_windowheapstore.go
- interface_processes_blockbuilder.go
- interface_processes_blockparentbuilder.go
- interface_processes_blockprocessor.go
- interface_processes_blockvalidator.go
- interface_processes_coinbasemanager.go
- interface_processes_consensusstatemanager.go
- interface_processes_dagtopologymanager.go
- interface_processes_dagtraversalmanager.go
- interface_processes_difficultymanager.go
- interface_processes_finalitymanager.go
- interface_processes_ghostdagmanager.go
- interface_processes_headertipsmanager.go
- interface_processes_mergedepthmanager.go
- interface_processes_parentsmanager.go
- interface_processes_pastmediantimemanager.go
- interface_processes_pruningmanager.go
- interface_processes_pruningproofmanager.go
- interface_processes_reachabilitytree.go
- interface_processes_syncmanager.go
- interface_processes_transactionvalidator.go
- multiset.go
- reachabilitydata.go
- staging_area.go
- store.go
- subdag.go
- utxo_diff_reversal_data.go
- virtual.go