model

package
v1.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2023 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDeserializeErr

func IsDeserializeErr(err error) bool

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
	// GetStatus
	GetStatus() BlockStatus
}

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
}

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

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
	VMBlockIndexStore() VMBlockIndexStore
	InvalidTxIndexStore() InvalidTxIndexStore
	Interrupt() <-chan struct{}
	Params() *params.Params
	VMService() VMI
	Rebuild() error
	AmanaService() service.IService
}

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 FeeEstimator interface {
	RegisterBlock(block *types.SerializedBlock) error
	Rollback(hash *hash.Hash) error
}

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, vmbid uint64) error

	// DisconnectBlock is invoked when a block has been disconnected from
	// the main chain.
	DisconnectBlock(block *types.SerializedBlock, stxos [][]byte, blk Block, vmbid uint64) 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

type StagingShard interface {
	Commit(dbTx database.Tx) 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 Store

type Store interface {
}

Store is a common interface for data stores

type Tx

type Tx interface {
	GetTxType() types.TxType
	GetFrom() string
	GetTo() string
	GetValue() uint64
	GetData() []byte
}

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 VMBlockIndexStore

type VMBlockIndexStore interface {
	Store
	Stage(stagingArea *StagingArea, bid uint64, bhash *hash.Hash)
	StageTip(stagingArea *StagingArea, bhash *hash.Hash, order uint64)
	IsStaged(stagingArea *StagingArea) bool
	Get(stagingArea *StagingArea, bid uint64) (*hash.Hash, error)
	Has(stagingArea *StagingArea, bid uint64) (bool, error)
	Delete(stagingArea *StagingArea, bid uint64)
	Tip(stagingArea *StagingArea) (uint64, *hash.Hash, error)
	IsEmpty() bool
	Clean() error
}

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
	GetBlockID(bh *hash.Hash) uint64
	GetBlockIDByTxHash(txhash *hash.Hash) uint64
	GetBalance(addr string) (int64, error)
	SetLogLevel(level string)
	GetBlockByNumber(num uint64) (interface{}, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL