chain

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBlockNotFound is returned when a block is not found.
	ErrBlockNotFound = errors.New("block not found")
	// ErrInvalidChangeID is returned to a subscriber when the change id is
	// invalid.
	ErrInvalidChangeID = errors.New("invalid change id")
)

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

A Manager manages the current state of the blockchain.

func NewManager

func NewManager(cs modules.ConsensusSet, tp *TransactionPool) (*Manager, error)

NewManager creates a new chain manager.

func (*Manager) AcceptBlock

func (m *Manager) AcceptBlock(b types.Block) error

AcceptBlock adds b to the consensus set.

func (*Manager) BlockAtHeight

func (m *Manager) BlockAtHeight(height uint64) (types.Block, bool)

BlockAtHeight returns the block at the given height.

func (*Manager) Close

func (m *Manager) Close() error

Close closes the chain manager.

func (*Manager) IndexAtHeight

func (m *Manager) IndexAtHeight(height uint64) (types.ChainIndex, error)

IndexAtHeight return the chain index at the given height.

func (*Manager) Network

func (m *Manager) Network() string

Network returns the network name.

func (*Manager) PoolTransactions added in v1.1.0

func (m *Manager) PoolTransactions() []types.Transaction

PoolTransactions returns all transactions in the transaction pool

func (*Manager) ProcessConsensusChange

func (m *Manager) ProcessConsensusChange(cc modules.ConsensusChange)

ProcessConsensusChange implements the modules.ConsensusSetSubscriber interface.

func (*Manager) Subscribe

func (m *Manager) Subscribe(s modules.ConsensusSetSubscriber, ccID modules.ConsensusChangeID, cancel <-chan struct{}) error

Subscribe subscribes to the consensus set.

func (*Manager) Synced

func (m *Manager) Synced() bool

Synced returns true if the chain manager is synced with the consensus set.

func (*Manager) TipState

func (m *Manager) TipState() consensus.State

TipState returns the current chain state.

type TransactionPool

type TransactionPool struct {
	// contains filtered or unexported fields
}

TransactionPool wraps the siad transaction pool with a more convenient API.

func NewTPool

NewTPool wraps a siad transaction pool with a more convenient API.

func (*TransactionPool) AcceptTransactionSet

func (tp *TransactionPool) AcceptTransactionSet(txns []types.Transaction) error

AcceptTransactionSet adds a transaction set to the tpool and broadcasts it to the network.

func (*TransactionPool) Close

func (tp *TransactionPool) Close() error

Close closes the transaction pool.

func (*TransactionPool) RecommendedFee

func (tp *TransactionPool) RecommendedFee() (fee types.Currency)

RecommendedFee returns the recommended fee per byte.

func (*TransactionPool) Subscribe

Subscribe subscribes to the transaction pool.

func (*TransactionPool) Transactions

func (tp *TransactionPool) Transactions() []types.Transaction

Transactions returns the transactions in the transaction pool.

func (*TransactionPool) UnconfirmedParents

func (tp *TransactionPool) UnconfirmedParents(txn types.Transaction) ([]types.Transaction, error)

UnconfirmedParents returns the unconfirmed parents of a transaction.

Jump to

Keyboard shortcuts

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