Documentation
¶
Index ¶
- func IsDeserializeErr(err error) bool
- type Acct
- type AssertError
- type Block
- type BlockChain
- type BlockState
- type BlockStatus
- type Consensus
- type DataBase
- type DifficultyManager
- type ErrDeserialize
- type FeeEstimator
- type IndexManager
- type InvalidTxIndexStore
- type MedianTimeSource
- type MeerChain
- type Notify
- type P2PService
- type StagingArea
- type StagingShard
- type StagingShardID
- type Store
- type Tx
- type TxManager
- type TxPool
- type TxStatus
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 BlockChain ¶
type BlockChain interface {
GetMainOrder() uint
FetchBlockByOrder(order uint64) (*types.SerializedBlock, Block, error)
FetchSpendJournalPKS(targetBlock *types.SerializedBlock) ([][]byte, error)
SetDAGDuplicateTxs(sblock *types.SerializedBlock, block Block)
GetBlockHashByOrder(order uint) *hash.Hash
BlockByOrder(blockOrder uint64) (*types.SerializedBlock, error)
Rebuild() error
GetMiningTips(expectPriority int) []*hash.Hash
GetBlockState(order uint64) BlockState
MeerChain() MeerChain
Start() error
Stop() error
GetBlockByOrder(order uint64) Block
GetBlockById(id uint) Block
GetMainChainTip() Block
FetchBlockByHash(hash *hash.Hash) (*types.SerializedBlock, error)
GetBlockOrderByHash(hash *hash.Hash) (uint, error)
GetBlockHeader(block Block) *types.BlockHeader
ForeachBlueBlocks(start Block, depth uint, powType pow.PowType, fn func(block Block, header *types.BlockHeader) error) error
}
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
BlockChain() BlockChain
IndexManager() IndexManager
Events() *event.Feed
MedianTimeSource() MedianTimeSource
SigCache() *txscript.SigCache
Interrupt() <-chan struct{}
Params() *params.Params
Rebuild() error
AmanaService() service.IService
Shutdown()
}
Consensus maintains the current core state of the node
type DataBase ¶ added in v1.2.0
type DataBase interface {
Name() string
Init() error
Close()
Rebuild(mgr IndexManager) error
GetInfo() (*common.DatabaseInfo, error)
PutInfo(di *common.DatabaseInfo) error
GetSpendJournal(bh *hash.Hash) ([]byte, error)
PutSpendJournal(bh *hash.Hash, data []byte) error
DeleteSpendJournal(bh *hash.Hash) error
GetUtxo(key []byte) ([]byte, error)
PutUtxo(key []byte, data []byte) error
DeleteUtxo(key []byte) error
ForeachUtxo(fn func(key []byte, data []byte) error) error
UpdateUtxo(opts []*common.UtxoOpt) error
GetTokenState(blockID uint) ([]byte, error)
PutTokenState(blockID uint, data []byte) error
DeleteTokenState(blockID uint) error
GetBestChainState() ([]byte, error)
PutBestChainState(data []byte) error
GetBlock(hash *hash.Hash) (*types.SerializedBlock, error)
GetBlockBytes(hash *hash.Hash) ([]byte, error)
GetHeader(hash *hash.Hash) (*types.BlockHeader, error)
PutBlock(block *types.SerializedBlock) error
HasBlock(hash *hash.Hash) bool
GetDagInfo() ([]byte, error)
PutDagInfo(data []byte) error
GetDAGBlock(blockID uint) ([]byte, error)
PutDAGBlock(blockID uint, data []byte) error
DeleteDAGBlock(blockID uint) error
GetDAGBlockIdByHash(bh *hash.Hash) (uint, error)
PutDAGBlockIdByHash(bh *hash.Hash, id uint) error
DeleteDAGBlockIdByHash(bh *hash.Hash) error
PutMainChainBlock(blockID uint) error
HasMainChainBlock(blockID uint) bool
DeleteMainChainBlock(blockID uint) error
PutBlockIdByOrder(order uint, id uint) error
GetBlockIdByOrder(order uint) (uint, error)
PutDAGTip(id uint, isMain bool) error
GetDAGTips() ([]uint, error)
DeleteDAGTip(id uint) error
PutDiffAnticone(id uint) error
GetDiffAnticones() ([]uint, error)
DeleteDiffAnticone(id uint) error
Get(key []byte) ([]byte, error)
Put(key []byte, value []byte) error
PutTxIdxEntrys(sblock *types.SerializedBlock, block Block) error
GetTxIdxEntry(id *hash.Hash, verbose bool) (*types.Tx, *hash.Hash, error)
DeleteTxIdxEntrys(block *types.SerializedBlock) error
PutTxHashs(block *types.SerializedBlock) error
GetTxIdByHash(fullHash *hash.Hash) (*hash.Hash, error)
DeleteTxHashs(block *types.SerializedBlock) error
IsInvalidTxIdxEmpty() bool
GetInvalidTxIdxTip() (uint64, *hash.Hash, error)
PutInvalidTxIdxTip(order uint64, bh *hash.Hash) error
PutInvalidTxs(sblock *types.SerializedBlock, block Block) error
DeleteInvalidTxs(sblock *types.SerializedBlock, block Block) error
GetInvalidTx(id *hash.Hash) (*types.Transaction, error)
GetInvalidTxIdByHash(fullHash *hash.Hash) (*hash.Hash, error)
CleanInvalidTxIdx() error
GetAddrIdxTip() (*hash.Hash, uint, error)
PutAddrIdxTip(bh *hash.Hash, order uint) error
PutAddrIdx(sblock *types.SerializedBlock, block Block, stxos [][]byte) error
GetTxForAddress(addr types.Address, numToSkip, numRequested uint32, reverse bool) ([]*common.RetrievedTx, uint32, error)
DeleteAddrIdx(sblock *types.SerializedBlock, stxos [][]byte) error
CleanAddrIdx(finish bool) error
IsLegacy() bool
TryUpgrade(di *common.DatabaseInfo, interrupt <-chan struct{}) error
GetEstimateFee() ([]byte, error)
PutEstimateFee(data []byte) error
DeleteEstimateFee() error
Snapshot() error
SnapshotInfo() string
DBEngine() string
StartTrack(info string) error
StopTrack() error
}
type DifficultyManager ¶ added in v1.2.0
type DifficultyManager interface {
RequiredDifficulty(block Block, newBlockTime time.Time, powInstance pow.IPow) (uint32, error)
CalcEasiestDifficulty(bits uint32, duration time.Duration, powInstance pow.IPow) uint32
GetCurrentPowDiff(ib Block, powType pow.PowType) *big.Int
}
DifficultyManager provides a method to resolve the difficulty value of a block
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(sblock *types.SerializedBlock, block Block, stxos [][]byte) error
// DisconnectBlock is invoked when a block has been disconnected from
// the main chain.
DisconnectBlock(sblock *types.SerializedBlock, block Block, stxos [][]byte) error
UpdateMainTip(bh *hash.Hash, order uint64) error
// IsDuplicateTx
IsDuplicateTx(txid *hash.Hash, blockHash *hash.Hash) bool
HasTx(txid *hash.Hash) bool
}
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 Notify ¶ added in v1.2.0
type Notify interface {
AnnounceNewTransactions(newTxs []*types.TxDesc, filters []peer.ID)
RelayInventory(block *types.SerializedBlock, flags uint32, source *peer.ID)
BroadcastMessage(data interface{})
TransactionConfirmed(tx *types.Tx)
TransactionsConfirmed(txs []*types.Tx)
AddRebroadcastInventory(newTxs []*types.TxDesc)
}
Notify interface manage message announce & relay & notification between mempool, websocket, gbt long pull and rpc server.
type P2PService ¶
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 legacydb.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(tx *types.Tx)
ProcessOrphans(tx *types.Tx) []*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
}