Documentation ¶
Index ¶
- Variables
- type AlgorithmManager
- type BlockBuilder
- type BlockHeaderStore
- type BlockIterator
- type BlockProcessor
- type BlockRelationStore
- type BlockRelations
- type BlockStatusStore
- type BlockStore
- type BlockValidator
- type CoinbaseManager
- type ConsensusStateManager
- type DBBucket
- type DBCursor
- type DBKey
- type DBManager
- type DBReader
- type DBTransaction
- type DBWriter
- type DifficultyManager
- type FinalityManager
- type FinalityStore
- type HeaderSelectedTipStore
- type HeadersSelectedChainStore
- type HeadersSelectedTipManager
- type MetTopologyManager
- type Multiset
- type MultisetStore
- type PastMedianTimeManager
- type StagingArea
- type StagingShard
- type StagingShardID
- type SyncManager
- type TransactionValidator
- type UTXODiffReversalData
- type UTXODiffStore
Constants ¶
This section is empty.
Variables ¶
var VirtualGenesisBlockHash = external.NewDomainHashFromByteArray(&[external.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,
})
Functions ¶
This section is empty.
Types ¶
type AlgorithmManager ¶
type AlgorithmManager interface { GetActiveMiningAlgo(stagingArea *StagingArea, blockHash *external.DomainHash, isBlockWithTrustedData bool) (uint32, error) VerifyMiningAlgo(stagingArea *StagingArea, blockHash *external.DomainHash) (uint32, error) BroadcastMiningAlgo(startHash *external.DomainHash, windowSize int) (uint64, error) SetAlgoBlockId() VerifyAlgoBlockId() SetDifficultyRetargetForAlgo() GetDifficultyRetargetForAlgo() VerifyDifficultyRetargetForAlgo() BroadcastDifficultyRetargetForAlgo() ConcensusAntiAsics() }
DifficultyManager provides a method to resolve the difficulty value of a block
type BlockBuilder ¶
type BlockBuilder interface { BuildBlockTemplate(coinbaseData *external.DomainCoinbaseData, transactions []*external.DomainTransaction) (block *external.DomainBlock, coinbaseHasRedReward bool, err error) BuildBlock(coinbaseData *external.TempBlock) (block *external.TempBlock, err error) }
BlockBuilder is responsible for creating blocks from the current state
type BlockHeaderStore ¶
type BlockHeaderStore interface { Stage(stagingArea *StagingArea, blockHash *external.DomainHash, blockHeader external.BlockHeader) IsStaged(stagingArea *StagingArea) bool BlockHeader(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (external.BlockHeader, error) HasBlockHeader(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (bool, error) BlockHeaders(dbContext DBReader, stagingArea *StagingArea, blockHashes []*external.DomainHash) ([]external.BlockHeader, error) Delete(stagingArea *StagingArea, blockHash *external.DomainHash) Count(stagingArea *StagingArea) uint64 }
BlockHeaderStore represents a store of block headers
type BlockIterator ¶
type BlockProcessor ¶
type BlockProcessor interface { ValidateAndInsertBlock(block *external.DomainBlock, shouldValidateAgainstUTXO bool) (*external.VirtualChangeSet, external.BlockStatus, error) ValidateAndInsertBlockWithTrustedData(block *external.BlockWithTrustedData, validateUTXO bool) (*external.VirtualChangeSet, external.BlockStatus, error) }
type BlockRelationStore ¶
type BlockRelationStore interface { StageBlockRelation(stagingArea *StagingArea, blockHash *external.DomainHash, blockRelations *BlockRelations) IsStaged(stagingArea *StagingArea) bool BlockRelation(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (*BlockRelations, error) Has(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (bool, error) UnstageAll(stagingArea *StagingArea) }
type BlockRelations ¶
type BlockRelations struct { Parents []*external.DomainHash Children []*external.DomainHash ParentMet []*external.DomainHash ParentMega []*external.DomainHash }
BlockRelations represents a block's parent/child relations
type BlockStatusStore ¶
type BlockStatusStore interface { Stage(stagingArea *StagingArea, blockHash *external.DomainHash, blockStatus external.BlockStatus) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (external.BlockStatus, error) Exists(dbContext database.Database, stagingArea *StagingArea, blockHash *external.DomainHash) (bool, error) }
BlockStatusStore represents a store of BlockStatuses
type BlockStore ¶
type BlockStore interface { Stage(stagingArea *StagingArea, blockHash *external.DomainHash, block *external.DomainBlock) IsStaged(stagingArea *StagingArea) bool Block(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (*external.DomainBlock, error) HasBlock(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (bool, error) Blocks(dbContext DBReader, stagingArea *StagingArea, blockHashes []*external.DomainHash) ([]*external.DomainBlock, error) Delete(stagingArea *StagingArea, blockHash *external.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 *external.DomainHash) error ValidateBodyInIsolation(stagingArea *StagingArea, blockHash *external.DomainHash) error ValidateHeaderInContext(stagingArea *StagingArea, blockHash *external.DomainHash, isBlockWithTrustedData bool) error ValidateBodyInContext(stagingArea *StagingArea, blockHash *external.DomainHash, isBlockWithTrustedData bool) error ValidatePruningPointViolationAndProofOfWorkAndDifficulty(stagingArea *StagingArea, blockHash *external.DomainHash, isBlockWithTrustedData bool) 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 *external.DomainHash, coinbaseData *external.DomainCoinbaseData) (expectedTransaction *external.DomainTransaction, hasRedReward bool, err error) CalcBlockSubsidy(stagingArea *StagingArea, blockHash *external.DomainHash) (uint64, error) ExtractCoinbaseDataBlueScoreAndSubsidy(coinbaseTx *external.DomainTransaction) (blueScore uint64, coinbaseData *external.DomainCoinbaseData, subsidy uint64, err error) }
CoinbaseManager exposes methods for handling blocks' coinbase transactions
type ConsensusStateManager ¶
type ConsensusStateManager interface { // Add Block function to be created AddBlock(stagingArea *StagingArea, blockHash *external.DomainHash, updateVirtual bool) (*external.SelectedChainPath, external.UTXODiff, *UTXODiffReversalData, error) PopulateTransactionWithUTXOEntries(stagingArea *StagingArea, transaction *external.DomainTransaction) error RestorePastUTXOSetIterator(stagingArea *StagingArea, blockHash *external.DomainHash) (external.ReadOnlyUTXOSetIterator, error) GetVirtualSelectedParentChainFromBlock(stagingArea *StagingArea, blockHash *external.DomainHash) (*external.SelectedChainPath, error) }
type DBBucket ¶
type DBBucket interface { Bucket(bucketBytes []byte) database.Bucket Key(suffix []byte) database.Key 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 database.Key) 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) Last() bool // 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) }
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 *external.DomainHash, isBlockWithTrustedData bool) (uint32, error) RequiredDifficulty(stagingArea *StagingArea, blockHash *external.DomainHash) (uint32, error) EstimateNetworkHashesPerSecond(startHash *external.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) (*external.DomainHash, error) FinalityPoint(stagingArea *StagingArea, blockHash *external.DomainHash, isBlockWithTrustedData bool) (*external.DomainHash, error) }
FinalityManager provides method to validate that a block does not violate finality
type FinalityStore ¶
type FinalityStore interface { IsStaged(stagingArea *StagingArea) bool StageFinalityPoint(stagingArea *StagingArea, blockHash *external.DomainHash, finalityPointHash *external.DomainHash) FinalityPoint(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (*external.DomainHash, error) }
FinalityStore represents a store for finality data
type HeaderSelectedTipStore ¶
type HeaderSelectedTipStore interface { Stage(stagingArea *StagingArea, selectedTip *external.DomainHash) IsStaged(stagingArea *StagingArea) bool HeadersSelectedTip(dbContext DBReader, stagingArea *StagingArea) (*external.DomainHash, error) Has(dbContext DBReader, stagingArea *StagingArea) (bool, error) }
HeaderSelectedTipStore represents a store of the headers selected tip
type HeadersSelectedChainStore ¶
type HeadersSelectedChainStore interface { Stage(dbContext DBReader, stagingArea *StagingArea, chainChanges *external.SelectedChainPath) error IsStaged(stagingArea *StagingArea) bool GetIndexByHash(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (uint64, error) GetHashByIndex(dbContext DBReader, stagingArea *StagingArea, index uint64) (*external.DomainHash, error) }
type HeadersSelectedTipManager ¶
type HeadersSelectedTipManager interface {
AddHeaderTip(stagingArea *StagingArea, hash *external.DomainHash) error
}
HeadersSelectedTipManager manages the state of the headers selected tip
type MetTopologyManager ¶
type MetTopologyManager interface { Parents(stagingArea *StagingArea, blockHash *external.DomainHash) ([]*external.DomainHash, error) Children(stagingArea *StagingArea, blockHash *external.DomainHash) ([]*external.DomainHash, error) IsParentOf(stagingArea *StagingArea, blockHashA *external.DomainHash, blockHashB *external.DomainHash) (bool, error) IsChildOf(stagingArea *StagingArea, blockHashA *external.DomainHash, blockHashB *external.DomainHash) (bool, error) IsAncestorOf(stagingArea *StagingArea, blockHashA *external.DomainHash, blockHashB *external.DomainHash) (bool, error) IsAncestorOfAny(stagingArea *StagingArea, blockHash *external.DomainHash, potentialDescendants []*external.DomainHash) (bool, error) IsAnyAncestorOf(stagingArea *StagingArea, potentialAncestors []*external.DomainHash, blockHash *external.DomainHash) (bool, error) IsInSelectedParentChainOf(stagingArea *StagingArea, blockHashA *external.DomainHash, blockHashB *external.DomainHash) (bool, error) ChildInSelectedParentChainOf(stagingArea *StagingArea, lowHash, highHash *external.DomainHash) (*external.DomainHash, error) SetParents(stagingArea *StagingArea, blockHash *external.DomainHash, parentHashes []*external.DomainHash) error }
type Multiset ¶
type Multiset interface { Add(data []byte) Remove(data []byte) Hash() *external.DomainHash Serialize() []byte Clone() Multiset }
Multiset represents a secp256k1 multiset
type MultisetStore ¶
type MultisetStore interface { Stage(stagingArea *StagingArea, blockHash *external.DomainHash, multiset Multiset) IsStaged(stagingArea *StagingArea) bool Get(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (Multiset, error) Delete(stagingArea *StagingArea, blockHash *external.DomainHash) }
MultisetStore represents a store of Multisets
type PastMedianTimeManager ¶
type PastMedianTimeManager interface { PastMedianTime(stagingArea *StagingArea, blockHash *external.DomainHash) (int64, error) InvalidateVirtualPastMedianTimeCache() }
PastMedianTimeManager provides a method to resolve the past median time of a block
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 database.Transaction) 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.
type StagingShard ¶
type StagingShard interface {
Commit(dbTx database.Transaction) 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 SyncManager ¶
type SyncManager interface { GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *external.DomainHash, maxBlocks uint64) ( hashes []*external.DomainHash, actualHighHash *external.DomainHash, err error) GetAnticone(stagingArea *StagingArea, blockHash, contextHash *external.DomainHash, maxBlocks uint64) (hashes []*external.DomainHash, err error) GetMissingBlockBodyHashes(stagingArea *StagingArea, highHash *external.DomainHash) ([]*external.DomainHash, error) CreateBlockLocator(stagingArea *StagingArea, lowHash, highHash *external.DomainHash, limit uint32) ( external.BlockLocator, error) CreateHeadersSelectedChainBlockLocator(stagingArea *StagingArea, lowHash, highHash *external.DomainHash) ( external.BlockLocator, error) GetSyncInfo(stagingArea *StagingArea) (*external.SyncInfo, error) }
type TransactionValidator ¶
type TransactionValidator interface { ValidateTransactionInIsolation(transaction *external.DomainTransaction, povDAAScore uint64) error ValidateTransactionInContextIgnoringUTXO(stagingArea *StagingArea, tx *external.DomainTransaction, povBlockHash *external.DomainHash, povBlockPastMedianTime int64) error ValidateTransactionInContextAndPopulateFee(stagingArea *StagingArea, tx *external.DomainTransaction, povBlockHash *external.DomainHash) error PopulateMass(transaction *external.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 *external.DomainHash SelectedParentUTXODiff external.UTXODiff }
UTXODiffReversalData is used by ConsensusStateManager to reverse the UTXODiffs during a re-org
type UTXODiffStore ¶
type UTXODiffStore interface { Stage(stagingArea *StagingArea, blockHash *external.DomainHash, utxoDiff external.UTXODiff, utxoDiffChild *external.DomainHash) IsStaged(stagingArea *StagingArea) bool UTXODiff(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (external.UTXODiff, error) UTXODiffChild(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (*external.DomainHash, error) HasUTXODiffChild(dbContext DBReader, stagingArea *StagingArea, blockHash *external.DomainHash) (bool, error) Delete(stagingArea *StagingArea, blockHash *external.DomainHash) }
UTXODiffStore represents a store of UTXODiffs
Source Files ¶
- Consensus_state_manager.go
- Met_G_Data_store.go
- Met_G_manager.go
- algorithm_manager.go
- block_builder.go
- block_header_store.go
- block_iterator.go
- block_processor.go
- block_releation.go
- block_releation_store.go
- block_status_store.go
- block_store.go
- blockvalidator.go
- coinbase_manager.go
- db.go
- difficulty_manager.go
- finality_manager.go
- finalitystore.go
- header_selected_tip_manager.go
- headerselectchainstore.go
- headertipsstore.go
- metpology_manager.go
- multiset.go
- past_median_time.go
- staging_area.go
- sync_manager.go
- transaction_validator.go
- utxo_diff_reversal_data.go
- virtual.go