Documentation ¶
Index ¶
- Variables
- type AcceptanceDataStore
- type BlockBuilder
- type BlockGHOSTDAGData
- func (bgd *BlockGHOSTDAGData) BlueScore() uint64
- func (bgd *BlockGHOSTDAGData) BlueWork() *big.Int
- func (bgd *BlockGHOSTDAGData) BluesAnticoneSizes() map[externalapi.DomainHash]KType
- func (bgd *BlockGHOSTDAGData) MergeSet() []*externalapi.DomainHash
- func (bgd *BlockGHOSTDAGData) MergeSetBlues() []*externalapi.DomainHash
- func (bgd *BlockGHOSTDAGData) MergeSetReds() []*externalapi.DomainHash
- func (bgd *BlockGHOSTDAGData) SelectedParent() *externalapi.DomainHash
- type BlockHeaderStore
- type BlockHeap
- type BlockIterator
- type BlockProcessor
- type BlockRelationStore
- type BlockRelations
- type BlockStatusStore
- type BlockStore
- type BlockValidator
- 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 KType
- type MergeDepthManager
- type Multiset
- type MultisetStore
- type MutableReachabilityData
- type PastMedianTimeManager
- type PruningManager
- type PruningStore
- type ReachabilityData
- type ReachabilityDataStore
- type ReachabilityInterval
- type ReachabilityManager
- type StagingArea
- type StagingShard
- type StagingShardID
- type Store
- type SyncManager
- type TransactionValidator
- type UTXODiffStore
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 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
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) (*externalapi.DomainBlock, error)
}
BlockBuilder is responsible for creating blocks from the current state
type BlockGHOSTDAGData ¶
type BlockGHOSTDAGData struct {
// contains filtered or unexported fields
}
BlockGHOSTDAGData represents GHOSTDAG data for some block
func NewBlockGHOSTDAGData ¶
func NewBlockGHOSTDAGData( blueScore uint64, blueWork *big.Int, selectedParent *externalapi.DomainHash, mergeSetBlues []*externalapi.DomainHash, mergeSetReds []*externalapi.DomainHash, bluesAnticoneSizes map[externalapi.DomainHash]KType) *BlockGHOSTDAGData
NewBlockGHOSTDAGData creates a new instance of BlockGHOSTDAGData
func (*BlockGHOSTDAGData) BlueScore ¶
func (bgd *BlockGHOSTDAGData) BlueScore() uint64
BlueScore returns the BlueScore of the block
func (*BlockGHOSTDAGData) BlueWork ¶
func (bgd *BlockGHOSTDAGData) BlueWork() *big.Int
BlueWork returns the BlueWork of the block
func (*BlockGHOSTDAGData) BluesAnticoneSizes ¶
func (bgd *BlockGHOSTDAGData) BluesAnticoneSizes() map[externalapi.DomainHash]KType
BluesAnticoneSizes returns a map between the blocks in its MergeSetBlues and the size of their anticone
func (*BlockGHOSTDAGData) MergeSet ¶
func (bgd *BlockGHOSTDAGData) MergeSet() []*externalapi.DomainHash
MergeSet returns the whole MergeSet of the block (equivalent to MergeSetBlues+MergeSetReds)
func (*BlockGHOSTDAGData) MergeSetBlues ¶
func (bgd *BlockGHOSTDAGData) MergeSetBlues() []*externalapi.DomainHash
MergeSetBlues returns the MergeSetBlues of the block (not a copy)
func (*BlockGHOSTDAGData) MergeSetReds ¶
func (bgd *BlockGHOSTDAGData) MergeSetReds() []*externalapi.DomainHash
MergeSetReds returns the MergeSetReds of the block (not a copy)
func (*BlockGHOSTDAGData) SelectedParent ¶
func (bgd *BlockGHOSTDAGData) SelectedParent() *externalapi.DomainHash
SelectedParent returns the SelectedParent of the block
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 BlockProcessor ¶
type BlockProcessor interface { ValidateAndInsertBlock(block *externalapi.DomainBlock) (*externalapi.BlockInsertionResult, error) ValidateAndInsertImportedPruningPoint(newPruningPoint *externalapi.DomainBlock) 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) }
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) error ValidateBodyInContext(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isPruningPoint bool) error ValidatePruningPointViolationAndProofOfWorkAndDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) error }
BlockValidator exposes a set of validation classes, after which it's possible to determine whether a block is valid
type CoinbaseManager ¶
type CoinbaseManager interface { ExpectedCoinbaseTransaction(stagingArea *StagingArea, blockHash *externalapi.DomainHash, coinbaseData *externalapi.DomainCoinbaseData) (*externalapi.DomainTransaction, error) ExtractCoinbaseDataAndBlueScore(coinbaseTx *externalapi.DomainTransaction) (blueScore uint64, coinbaseData *externalapi.DomainCoinbaseData, err error) }
CoinbaseManager exposes methods for handling blocks' coinbase transactions
type ConsensusStateManager ¶
type ConsensusStateManager interface { AddBlock(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*externalapi.SelectedChainPath, externalapi.UTXODiff, error) PopulateTransactionWithUTXOEntries(stagingArea *StagingArea, transaction *externalapi.DomainTransaction) error ImportPruningPoint(stagingArea *StagingArea, newPruningPoint *externalapi.DomainBlock) 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 }
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 ¶ added in v0.10.0
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, context, 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 { BlockAtDepth(stagingArea *StagingArea, highHash *externalapi.DomainHash, depth uint64) (*externalapi.DomainHash, error) 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) (BlockIterator, error) Anticone(stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) BlockWindow(stagingArea *StagingArea, highHash *externalapi.DomainHash, windowSize int) ([]*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) (uint32, error) RequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, 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) (*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 *BlockGHOSTDAGData) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *externalapi.DomainHash) (*BlockGHOSTDAGData, error) }
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 *BlockGHOSTDAGData, blockHashB *externalapi.DomainHash, ghostdagDataB *BlockGHOSTDAGData) bool }
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) error NonBoundedMergeDepthViolatingBlues(stagingArea *StagingArea, blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) }
MergeDepthManager is used to validate mergeDepth for blocks
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 PastMedianTimeManager ¶
type PastMedianTimeManager interface {
PastMedianTime(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (int64, error)
}
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) ClearImportedPruningPointData() error AppendImportedPruningPointUTXOs(outpointAndUTXOEntryPairs []*externalapi.OutpointAndUTXOEntryPair) error UpdatePruningPointIfRequired() error PruneAllBlocksBelow(stagingArea *StagingArea, pruningPointHash *externalapi.DomainHash) error }
PruningManager resolves and manages the current pruning point
type PruningStore ¶
type PruningStore interface { Store StagePruningPoint(stagingArea *StagingArea, pruningPointBlockHash *externalapi.DomainHash) StagePreviousPruningPoint(stagingArea *StagingArea, oldPruningPointBlockHash *externalapi.DomainHash) 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) PreviousPruningPoint(dbContext DBReader, stagingArea *StagingArea) (*externalapi.DomainHash, error) PruningPoint(dbContext DBReader, stagingArea *StagingArea) (*externalapi.DomainHash, error) HasPruningPoint(dbContext DBReader, stagingArea *StagingArea) (bool, 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) }
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 { 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 ¶ added in v0.10.0
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 ¶ added in v0.10.0
func NewStagingArea() *StagingArea
NewStagingArea creates a new, empty staging area.
func (*StagingArea) Commit ¶ added in v0.10.0
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 ¶ added in v0.10.0
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 ¶ added in v0.10.0
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 ¶ added in v0.10.0
type StagingShardID byte
StagingShardID is used to identify each of the store's staging shards
const ( StagingShardIDAcceptanceData StagingShardID = iota StagingShardIDBlockHeader StagingShardIDBlockRelation StagingShardIDBlockStatus StagingShardIDBlock StagingShardIDConsensusState StagingShardIDDAABlocks StagingShardIDFinality StagingShardIDGHOSTDAG StagingShardIDHeadersSelectedChain StagingShardIDHeadersSelectedTip StagingShardIDMultiset StagingShardIDPruning StagingShardIDReachabilityData StagingShardIDUTXODiff // Always leave StagingShardIDLen as the last constant StagingShardIDLen )
StagingShardID constants
type SyncManager ¶
type SyncManager interface { GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) ( hashes []*externalapi.DomainHash, actualHighHash *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 kaspad nodes
type TransactionValidator ¶
type TransactionValidator interface { ValidateTransactionInIsolation(transaction *externalapi.DomainTransaction) error ValidateTransactionInContextAndPopulateMassAndFee(stagingArea *StagingArea, tx *externalapi.DomainTransaction, povBlockHash *externalapi.DomainHash, selectedParentMedianTime int64) error }
TransactionValidator exposes a set of validation classes, after which it's possible to determine whether a transaction is valid
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
Source Files ¶
- block_heap.go
- blockiterator.go
- blockrelations.go
- database.go
- errors.go
- ghostdag.go
- interface_datastructures_acceptancedatastore.go
- interface_datastructures_blockheaderstore.go
- interface_datastructures_blockrelationstore.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_multisetstore.go
- interface_datastructures_pruningstore.go
- interface_datastructures_reachabilitydatastore.go
- interface_datastructures_utxodiffstore.go
- interface_processes_blockbuilder.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_pastmediantimemanager.go
- interface_processes_pruningmanager.go
- interface_processes_reachabilitytree.go
- interface_processes_syncmanager.go
- interface_processes_transactionvalidator.go
- multiset.go
- reachabilitydata.go
- staging_area.go
- store.go
- virtual.go