Documentation ¶
Index ¶
- Constants
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- type ChainMonitor
- type ReorgData
- type StakeDatabase
- func (db *StakeDatabase) ConnectBlock(block *dcrutil.Block) error
- func (db *StakeDatabase) ConnectBlockHash(hash *chainhash.Hash) (*dcrutil.Block, error)
- func (db *StakeDatabase) DBPrevBlock() (*dcrutil.Block, error)
- func (db *StakeDatabase) DBPrevBlockHeader() (*wire.BlockHeader, error)
- func (db *StakeDatabase) DBState() (uint32, *chainhash.Hash, error)
- func (db *StakeDatabase) DBTipBlock() (*dcrutil.Block, error)
- func (db *StakeDatabase) DBTipBlockHeader() (*wire.BlockHeader, error)
- func (db *StakeDatabase) DisconnectBlock() error
- func (db *StakeDatabase) DisconnectBlocks(count int64) error
- func (db *StakeDatabase) ForgetBlock(ind int64)
- func (db *StakeDatabase) Height() uint32
- func (db *StakeDatabase) NewChainMonitor(quit chan struct{}, wg *sync.WaitGroup, blockChan chan *chainhash.Hash, ...) *ChainMonitor
- func (db *StakeDatabase) Open() error
- func (db *StakeDatabase) PoolInfo() apitypes.TicketPoolInfo
- func (db *StakeDatabase) PoolSize() int
Constants ¶
const (
// DefaultStakeDbName is the default database name
DefaultStakeDbName = "ffldb_stake"
)
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type ChainMonitor ¶
type ChainMonitor struct {
// contains filtered or unexported fields
}
ChainMonitor connects blocks to the stake DB as they come in.
func (*ChainMonitor) BlockConnectedHandler ¶
func (p *ChainMonitor) BlockConnectedHandler()
BlockConnectedHandler handles block connected notifications, which trigger data collection and storage.
func (*ChainMonitor) ReorgHandler ¶
func (p *ChainMonitor) ReorgHandler()
ReorgHandler receives notification of a chain reorganization and initiates a corresponding reorganization of the stakedb.StakeDatabase.
type ReorgData ¶
type ReorgData struct { OldChainHead chainhash.Hash OldChainHeight int32 NewChainHead chainhash.Hash NewChainHeight int32 }
ReorgData contains the information from a reoranization notification
type StakeDatabase ¶
type StakeDatabase struct { NodeClient *dcrrpcclient.Client StakeDB database.DB BestNode *stake.Node ConnectingLock chan struct{} // contains filtered or unexported fields }
func NewStakeDatabase ¶
func NewStakeDatabase(client *dcrrpcclient.Client, params *chaincfg.Params) (*StakeDatabase, error)
NewStakeDatabase creates a StakeDatabase instance, opening or creating a new ffldb-backed stake database, and loads all live tickets into a cache.
func (*StakeDatabase) ConnectBlock ¶
func (db *StakeDatabase) ConnectBlock(block *dcrutil.Block) error
ConnectBlock connects the input block to the tip of the stake DB and updates the best stake node. This exported function gets any revoked and spend tickets from the input block, and any maturing tickets from the past block in which those tickets would be found, and passes them to connectBlock.
func (*StakeDatabase) ConnectBlockHash ¶
ConnectBlockHash is a wrapper for ConnectBlock. For the input block hash, it gets the block from the node RPC client and calls ConnectBlock.
func (*StakeDatabase) DBPrevBlock ¶
func (db *StakeDatabase) DBPrevBlock() (*dcrutil.Block, error)
DBPrevBlock gets the dcrutil.Block for the previous best block in the stake database. It used DBState to get the best block hash, and the node RPC client to get the block itself.
func (*StakeDatabase) DBPrevBlockHeader ¶
func (db *StakeDatabase) DBPrevBlockHeader() (*wire.BlockHeader, error)
DBPrevBlockHeader gets the block header for the previous best block in the stake database. It used DBState to get the best block hash, and the node RPC client to get the header.
func (*StakeDatabase) DBState ¶
func (db *StakeDatabase) DBState() (uint32, *chainhash.Hash, error)
DBState queries the stake database for the best block height and hash.
func (*StakeDatabase) DBTipBlock ¶
func (db *StakeDatabase) DBTipBlock() (*dcrutil.Block, error)
DBTipBlock gets the dcrutil.Block for the current best block in the stake database. It used DBState to get the best block hash, and the node RPC client to get the block itself.
func (*StakeDatabase) DBTipBlockHeader ¶
func (db *StakeDatabase) DBTipBlockHeader() (*wire.BlockHeader, error)
DBTipBlockHeader gets the block header for the current best block in the stake database. It used DBState to get the best block hash, and the node RPC client to get the header.
func (*StakeDatabase) DisconnectBlock ¶
func (db *StakeDatabase) DisconnectBlock() error
DisconnectBlock attempts to disconnect the current best block from the stake DB and updates the best stake node.
func (*StakeDatabase) DisconnectBlocks ¶
func (db *StakeDatabase) DisconnectBlocks(count int64) error
DisconnectBlocks disconnects N blocks from the head of the chain.
func (*StakeDatabase) ForgetBlock ¶
func (db *StakeDatabase) ForgetBlock(ind int64)
ForgetBlock deletes the block with the input height from the block cache.
func (*StakeDatabase) Height ¶
func (db *StakeDatabase) Height() uint32
Height gets the block height of the best stake node. It is thread-safe, unlike using db.BestNode.Height(), and checks that the stake database is opened first.
func (*StakeDatabase) NewChainMonitor ¶
func (db *StakeDatabase) NewChainMonitor(quit chan struct{}, wg *sync.WaitGroup, blockChan chan *chainhash.Hash, reorgChan chan *ReorgData) *ChainMonitor
NewChainMonitor creates a new ChainMonitor
func (*StakeDatabase) Open ¶
func (db *StakeDatabase) Open() error
func (*StakeDatabase) PoolInfo ¶
func (db *StakeDatabase) PoolInfo() apitypes.TicketPoolInfo
PoolInfo computes ticket pool value using the database and, if needed, the node RPC client to fetch ticket values that are not cached. Returned are a structure including ticket pool value, size, and average value.
func (*StakeDatabase) PoolSize ¶
func (db *StakeDatabase) PoolSize() int
PoolSize returns the ticket pool size in the best node of the stake database