Documentation ¶
Index ¶
- Variables
- type ChainSource
- type ChainscanNotifier
- func (n *ChainscanNotifier) RegisterBlockEpochNtfn(bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error)
- func (n *ChainscanNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error)
- func (n *ChainscanNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)
- func (n *ChainscanNotifier) Start() error
- func (n *ChainscanNotifier) Started() bool
- func (n *ChainscanNotifier) Stop() error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChainNotifierShuttingDown is used when we are trying to // measure a spend notification when notifier is already stopped. ErrChainNotifierShuttingDown = errors.New("chainntnfs: system interrupt " + "while attempting to register for spend notification") )
Functions ¶
This section is empty.
Types ¶
type ChainSource ¶
type ChainSource interface { GetBlock(context.Context, *chainhash.Hash) (*wire.MsgBlock, error) CurrentTip(context.Context) (*chainhash.Hash, int32, error) ChainEvents(context.Context) <-chan chainscan.ChainEvent GetCFilter(context.Context, int32) (*chainhash.Hash, [16]byte, *gcs.FilterV2, error) GetBlockHash(context.Context, int32) (*chainhash.Hash, error) GetBlockHeader(context.Context, *chainhash.Hash) (*wire.BlockHeader, error) StoresReorgedHeaders() bool Run(context.Context) error }
type ChainscanNotifier ¶
type ChainscanNotifier struct {
// contains filtered or unexported fields
}
ChainscanNotifier implements the ChainNotifier interface by using the chainscan package components. Multiple concurrent clients are supported. All notifications are achieved via non-blocking sends on client channels.
NOTE: This assumes for the moment the backing chain source is a dcrwallet instance (either embedded or remote) so it makes assumptions about the kinds of things the wallet stores and how it behaves.
func New ¶
func New(chainSrc ChainSource, chainParams *chaincfg.Params, spendHintCache chainntnfs.SpendHintCache, confirmHintCache chainntnfs.ConfirmHintCache) (*ChainscanNotifier, error)
New returns a new ChainscanNotifier instance. This function assumes the dcrd node detailed in the passed configuration is already running, and willing to accept new websockets clients.
func (*ChainscanNotifier) RegisterBlockEpochNtfn ¶
func (n *ChainscanNotifier) RegisterBlockEpochNtfn( bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error)
RegisterBlockEpochNtfn returns a BlockEpochEvent which subscribes the caller to receive notifications, of each new block connected to the main chain. Clients have the option of passing in their best known block, which the notifier uses to check if they are behind on blocks and catch them up. If they do not provide one, then a notification will be dispatched immediately for the current tip of the chain upon a successful registration.
func (*ChainscanNotifier) RegisterConfirmationsNtfn ¶
func (n *ChainscanNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error)
RegisterConfirmationsNtfn registers an intent to be notified once the target txid/output script has reached numConfs confirmations on-chain. When intending to be notified of the confirmation of an output script, a nil txid must be used. The heightHint should represent the earliest height at which the txid/output script could have been included in the chain.
Progress on the number of confirmations left can be read from the 'Updates' channel. Once it has reached all of its confirmations, a notification will be sent across the 'Confirmed' channel.
func (*ChainscanNotifier) RegisterSpendNtfn ¶
func (n *ChainscanNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)
RegisterSpendNtfn registers an intent to be notified once the target outpoint/output script has been spent by a transaction on-chain. When intending to be notified of the spend of an output script, a nil outpoint must be used. The heightHint should represent the earliest height in the chain of the transaction that spent the outpoint/output script.
Once a spend of has been detected, the details of the spending event will be sent across the 'Spend' channel.
func (*ChainscanNotifier) Start ¶
func (n *ChainscanNotifier) Start() error
Start connects to the running dcrd node over websockets, registers for block notifications, and finally launches all related helper goroutines.
func (*ChainscanNotifier) Started ¶
func (n *ChainscanNotifier) Started() bool
Started returns true if this instance has been started, and false otherwise.
func (*ChainscanNotifier) Stop ¶
func (n *ChainscanNotifier) Stop() error
Stop shutsdown the ChainscanNotifier.