Documentation ¶
Index ¶
- func IsDeserializeErr(err error) bool
- type Acct
- type AssertError
- type Block
- type BlockChain
- type BlockState
- type BlockStatus
- type Consensus
- type ErrDeserialize
- type FeeEstimator
- type IndexManager
- type InvalidTxIndexStore
- type MedianTimeSource
- type P2PService
- type StagingArea
- type StagingShard
- type StagingShardID
- type Store
- type Tx
- type TxManager
- type TxPool
- type TxStatus
- type VMI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDeserializeErr ¶
isDeserializeErr returns whether or not the passed error is an errDeserialize error.
Types ¶
type Acct ¶
type Acct interface { Apply(add bool, op *types.TxOutPoint, entry interface{}) error Commit() error }
type AssertError ¶
type AssertError string
AssertError identifies an error that indicates an internal code consistency issue and should be treated as a critical and unrecoverable error.
func (AssertError) Error ¶
func (e AssertError) Error() string
Error returns the assertion error as a huma-readable string and satisfies the error interface.
type Block ¶
type Block interface { GetID() uint GetState() BlockState }
type BlockChain ¶
type BlockChain interface { GetMainOrder() uint FetchBlockByOrder(order uint64) (*types.SerializedBlock, Block, error) FetchSpendJournalPKS(targetBlock *types.SerializedBlock) ([][]byte, error) CalculateDAGDuplicateTxs(block *types.SerializedBlock) GetBlockHashByOrder(order uint) *hash.Hash BlockByOrder(blockOrder uint64) (*types.SerializedBlock, error) Rebuild() error GetMiningTips(expectPriority int) []*hash.Hash GetBlockState(order uint64) BlockState }
type BlockState ¶ added in v1.0.21
type BlockState interface { GetID() uint64 SetOrder(order uint64) GetOrder() uint64 IsOrdered() bool SetWeight(weight uint64) GetWeight() uint64 GetStatus() BlockStatus Valid() Invalid() Root() *hash.Hash Bytes() ([]byte, error) GetEVMRoot() common.Hash GetEVMHash() common.Hash GetEVMNumber() uint64 SetEVM(header *etypes.Header) GetDuplicateTxs() []int Update(block *types.SerializedBlock, prev BlockState, header *etypes.Header) }
type BlockStatus ¶
type BlockStatus byte
BlockStatus
const ( // StatusNone StatusNone BlockStatus = 0 // StatusBadSide StatusBadSide BlockStatus = 1 << 0 // StatusInvalid indicates that the block data has failed validation. StatusInvalid BlockStatus = 1 << 2 )
func (BlockStatus) IsBadSide ¶
func (status BlockStatus) IsBadSide() bool
func (BlockStatus) KnownInvalid ¶
func (status BlockStatus) KnownInvalid() bool
func (BlockStatus) String ¶ added in v1.0.21
func (status BlockStatus) String() string
type Consensus ¶
type Consensus interface { Init() error GenesisHash() *hash.Hash Config() *config.Config DatabaseContext() database.DB BlockChain() BlockChain IndexManager() IndexManager Events() *event.Feed MedianTimeSource() MedianTimeSource SigCache() *txscript.SigCache InvalidTxIndexStore() InvalidTxIndexStore Interrupt() <-chan struct{} Params() *params.Params VMService() VMI Rebuild() error AmanaService() service.IService Shutdown() }
Consensus maintains the current core state of the node
type ErrDeserialize ¶
type ErrDeserialize string
ErrDeserialize signifies that a problem was encountered when deserializing data.
func (ErrDeserialize) Error ¶
func (e ErrDeserialize) Error() string
Error implements the error interface.
type FeeEstimator ¶
type IndexManager ¶
type IndexManager interface { // Init is invoked during chain initialize in order to allow the index // manager to initialize itself and any indexes it is managing. The // channel parameter specifies a channel the caller can close to signal // that the process should be interrupted. It can be nil if that // behavior is not desired. Init() error // ConnectBlock is invoked when a new block has been connected to the // main chain. ConnectBlock(block *types.SerializedBlock, stxos [][]byte, blk Block) error // DisconnectBlock is invoked when a block has been disconnected from // the main chain. DisconnectBlock(block *types.SerializedBlock, stxos [][]byte, blk Block) error UpdateMainTip(bh *hash.Hash, order uint64) error // IsDuplicateTx IsDuplicateTx(tx database.Tx, txid *hash.Hash, blockHash *hash.Hash) bool HasTx(txid *hash.Hash) bool Drop() error }
IndexManager provides a generic interface that the is called when blocks are connected and disconnected to and from the tip of the main chain for the purpose of supporting optional indexes.
type InvalidTxIndexStore ¶
type InvalidTxIndexStore interface { Store Stage(stagingArea *StagingArea, bid uint64, block *types.SerializedBlock) StageTip(stagingArea *StagingArea, bhash *hash.Hash, order uint64) IsStaged(stagingArea *StagingArea) bool Get(stagingArea *StagingArea, txid *hash.Hash) (*types.Transaction, error) GetIdByHash(stagingArea *StagingArea, h *hash.Hash) (*hash.Hash, error) Delete(stagingArea *StagingArea, bid uint64, block *types.SerializedBlock) Tip(stagingArea *StagingArea) (uint64, *hash.Hash, error) IsEmpty() bool Clean() error }
type MedianTimeSource ¶
type MedianTimeSource interface { // AdjustedTime returns the current time adjusted by the median time // offset as calculated from the time samples added by AddTimeSample. AdjustedTime() time.Time // AddTimeSample adds a time sample that is used when determining the // median time of the added samples. AddTimeSample(id string, timeVal time.Time) // Offset returns the number of seconds to adjust the local clock based // upon the median of the time samples added by AddTimeData. Offset() time.Duration }
MedianTimeSource provides a mechanism to add several time samples which are used to determine a median time which is then used as an offset to the local clock.
type P2PService ¶
type P2PService interface {
IsCurrent() bool
}
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.Tx) 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 ¶
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 TxManager ¶
type TxManager interface { MemPool() TxPool FeeEstimator() FeeEstimator InitDefaultFeeEstimator() }
type TxPool ¶
type TxPool interface { RemoveTransaction(tx *types.Tx, removeRedeemers bool) RemoveDoubleSpends(tx *types.Tx) RemoveOrphan(txHash *hash.Hash) ProcessOrphans(hash *hash.Hash) []*types.TxDesc MaybeAcceptTransaction(tx *types.Tx, isNew, rateLimit bool) ([]*hash.Hash, error) HaveTransaction(hash *hash.Hash) bool PruneExpiredTx() ProcessTransaction(tx *types.Tx, allowOrphan, rateLimit, allowHighFees bool) ([]*types.TxDesc, error) GetMainHeight() int64 AddTransaction(tx *types.Tx, height uint64, fee int64) IsSupportVMTx() bool }
type VMI ¶
type VMI interface { VerifyTx(tx Tx) (int64, error) VerifyTxSanity(tx Tx) error CheckConnectBlock(block *types.SerializedBlock) error ConnectBlock(block *types.SerializedBlock) (uint64, error) DisconnectBlock(block *types.SerializedBlock) (uint64, error) AddTxToMempool(tx *types.Transaction, local bool) (int64, error) RemoveTxFromMempool(tx *types.Transaction) error GetTxsFromMempool() ([]*types.Transaction, []*hash.Hash, error) GetMempoolSize() int64 ResetTemplate() error Genesis(txs []*types.Tx) *hash.Hash GetBlockIDByTxHash(txhash *hash.Hash) uint64 GetBalance(addr string) (int64, error) SetLogLevel(level string) GetBlockByNumber(num uint64) (interface{}, error) GetCurStateRoot() common.Hash GetCurHeader() *etypes.Header IsShutdown() bool RewindTo(state BlockState) error BlockChain() *core.BlockChain ChainDatabase() ethdb.Database PrepareEnvironment(state BlockState) (*etypes.Header, error) HasTx(h *hash.Hash) bool }