Documentation ¶
Index ¶
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- type BitcoindFilteredChainView
- func (b *BitcoindFilteredChainView) DisconnectedBlocks() <-chan *FilteredBlock
- func (b *BitcoindFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error)
- func (b *BitcoindFilteredChainView) FilteredBlocks() <-chan *FilteredBlock
- func (b *BitcoindFilteredChainView) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error)
- func (b *BitcoindFilteredChainView) Start() error
- func (b *BitcoindFilteredChainView) Stop() error
- func (b *BitcoindFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
- type BtcdFilteredChainView
- func (b *BtcdFilteredChainView) DisconnectedBlocks() <-chan *FilteredBlock
- func (b *BtcdFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error)
- func (b *BtcdFilteredChainView) FilteredBlocks() <-chan *FilteredBlock
- func (b *BtcdFilteredChainView) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error)
- func (b *BtcdFilteredChainView) Start() error
- func (b *BtcdFilteredChainView) Stop() error
- func (b *BtcdFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
- type CfFilteredChainView
- func (c *CfFilteredChainView) DisconnectedBlocks() <-chan *FilteredBlock
- func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error)
- func (c *CfFilteredChainView) FilteredBlocks() <-chan *FilteredBlock
- func (c *CfFilteredChainView) GetBlock(hash chainhash.Hash) (*ltcutil.Block, error)
- func (c *CfFilteredChainView) Start() error
- func (c *CfFilteredChainView) Stop() error
- func (c *CfFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
- type FilteredBlock
- type FilteredChainView
Constants ¶
This section is empty.
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 BitcoindFilteredChainView ¶
type BitcoindFilteredChainView struct {
// contains filtered or unexported fields
}
BitcoindFilteredChainView is an implementation of the FilteredChainView interface which is backed by bitcoind.
func NewBitcoindFilteredChainView ¶
func NewBitcoindFilteredChainView( chainConn *chain.BitcoindConn, blockCache *blockcache.BlockCache) *BitcoindFilteredChainView
NewBitcoindFilteredChainView creates a new instance of a FilteredChainView from RPC credentials and a ZMQ socket address for a bitcoind instance.
func (*BitcoindFilteredChainView) DisconnectedBlocks ¶
func (b *BitcoindFilteredChainView) DisconnectedBlocks() <-chan *FilteredBlock
DisconnectedBlocks returns a receive only channel which will be sent upon with the empty filtered blocks of blocks which are disconnected from the main chain in the case of a re-org.
NOTE: This is part of the FilteredChainView interface.
func (*BitcoindFilteredChainView) FilterBlock ¶
func (b *BitcoindFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error)
FilterBlock takes a block hash, and returns a FilteredBlocks which is the result of applying the current registered UTXO sub-set on the block corresponding to that block hash. If any watched UTOX's are spent by the selected lock, then the internal chainFilter will also be updated.
NOTE: This is part of the FilteredChainView interface.
func (*BitcoindFilteredChainView) FilteredBlocks ¶
func (b *BitcoindFilteredChainView) FilteredBlocks() <-chan *FilteredBlock
FilteredBlocks returns the channel that filtered blocks are to be sent over. Each time a block is connected to the end of a main chain, and appropriate FilteredBlock which contains the transactions which mutate our watched UTXO set is to be returned.
NOTE: This is part of the FilteredChainView interface.
func (*BitcoindFilteredChainView) GetBlock ¶
GetBlock is used to retrieve the block with the given hash. This function wraps the blockCache's GetBlock function.
func (*BitcoindFilteredChainView) Start ¶
func (b *BitcoindFilteredChainView) Start() error
Start starts all goroutines necessary for normal operation.
NOTE: This is part of the FilteredChainView interface.
func (*BitcoindFilteredChainView) Stop ¶
func (b *BitcoindFilteredChainView) Stop() error
Stop stops all goroutines which we launched by the prior call to the Start method.
NOTE: This is part of the FilteredChainView interface.
func (*BitcoindFilteredChainView) UpdateFilter ¶
func (b *BitcoindFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
UpdateFilter updates the UTXO filter which is to be consulted when creating FilteredBlocks to be sent to subscribed clients. This method is cumulative meaning repeated calls to this method should _expand_ the size of the UTXO sub-set currently being watched. If the set updateHeight is _lower_ than the best known height of the implementation, then the state should be rewound to ensure all relevant notifications are dispatched.
NOTE: This is part of the FilteredChainView interface.
type BtcdFilteredChainView ¶
type BtcdFilteredChainView struct {
// contains filtered or unexported fields
}
BtcdFilteredChainView is an implementation of the FilteredChainView interface which is backed by an active websockets connection to ltcd.
func NewBtcdFilteredChainView ¶
func NewBtcdFilteredChainView(config rpcclient.ConnConfig, blockCache *blockcache.BlockCache) (*BtcdFilteredChainView, error)
NewBtcdFilteredChainView creates a new instance of a FilteredChainView from RPC credentials for an active btcd instance.
func (*BtcdFilteredChainView) DisconnectedBlocks ¶
func (b *BtcdFilteredChainView) DisconnectedBlocks() <-chan *FilteredBlock
DisconnectedBlocks returns a receive only channel which will be sent upon with the empty filtered blocks of blocks which are disconnected from the main chain in the case of a re-org.
NOTE: This is part of the FilteredChainView interface.
func (*BtcdFilteredChainView) FilterBlock ¶
func (b *BtcdFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error)
FilterBlock takes a block hash, and returns a FilteredBlocks which is the result of applying the current registered UTXO sub-set on the block corresponding to that block hash. If any watched UTOX's are spent by the selected lock, then the internal chainFilter will also be updated.
NOTE: This is part of the FilteredChainView interface.
func (*BtcdFilteredChainView) FilteredBlocks ¶
func (b *BtcdFilteredChainView) FilteredBlocks() <-chan *FilteredBlock
FilteredBlocks returns the channel that filtered blocks are to be sent over. Each time a block is connected to the end of a main chain, and appropriate FilteredBlock which contains the transactions which mutate our watched UTXO set is to be returned.
NOTE: This is part of the FilteredChainView interface.
func (*BtcdFilteredChainView) GetBlock ¶
GetBlock is used to retrieve the block with the given hash. This function wraps the blockCache's GetBlock function.
func (*BtcdFilteredChainView) Start ¶
func (b *BtcdFilteredChainView) Start() error
Start starts all goroutines necessary for normal operation.
NOTE: This is part of the FilteredChainView interface.
func (*BtcdFilteredChainView) Stop ¶
func (b *BtcdFilteredChainView) Stop() error
Stop stops all goroutines which we launched by the prior call to the Start method.
NOTE: This is part of the FilteredChainView interface.
func (*BtcdFilteredChainView) UpdateFilter ¶
func (b *BtcdFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
UpdateFilter updates the UTXO filter which is to be consulted when creating FilteredBlocks to be sent to subscribed clients. This method is cumulative meaning repeated calls to this method should _expand_ the size of the UTXO sub-set currently being watched. If the set updateHeight is _lower_ than the best known height of the implementation, then the state should be rewound to ensure all relevant notifications are dispatched.
NOTE: This is part of the FilteredChainView interface.
type CfFilteredChainView ¶
type CfFilteredChainView struct {
// contains filtered or unexported fields
}
CfFilteredChainView is an implementation of the FilteredChainView interface which is supported by an underlying Bitcoin light client which supports client side filtering of Golomb Coded Sets. Rather than fetching all the blocks, the light client is able to query filters locally, to test if an item in a block modifies any of our watched set of UTXOs.
func NewCfFilteredChainView ¶
func NewCfFilteredChainView(node *neutrino.ChainService, blockCache *blockcache.BlockCache) (*CfFilteredChainView, error)
NewCfFilteredChainView creates a new instance of the CfFilteredChainView which is connected to an active neutrino node.
NOTE: The node should already be running and syncing before being passed into this function.
func (*CfFilteredChainView) DisconnectedBlocks ¶
func (c *CfFilteredChainView) DisconnectedBlocks() <-chan *FilteredBlock
DisconnectedBlocks returns a receive only channel which will be sent upon with the empty filtered blocks of blocks which are disconnected from the main chain in the case of a re-org.
NOTE: This is part of the FilteredChainView interface.
func (*CfFilteredChainView) FilterBlock ¶
func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error)
FilterBlock takes a block hash, and returns a FilteredBlocks which is the result of applying the current registered UTXO sub-set on the block corresponding to that block hash. If any watched UTXO's are spent by the selected lock, then the internal chainFilter will also be updated.
NOTE: This is part of the FilteredChainView interface.
func (*CfFilteredChainView) FilteredBlocks ¶
func (c *CfFilteredChainView) FilteredBlocks() <-chan *FilteredBlock
FilteredBlocks returns the channel that filtered blocks are to be sent over. Each time a block is connected to the end of a main chain, and appropriate FilteredBlock which contains the transactions which mutate our watched UTXO set is to be returned.
NOTE: This is part of the FilteredChainView interface.
func (*CfFilteredChainView) GetBlock ¶
GetBlock is used to retrieve the block with the given hash. Since the block cache used by neutrino will be the same as that used by LND (since it is passed to neutrino on initialisation), the neutrino GetBlock method can be called directly since it already uses the block cache. However, neutrino does not lock the block cache mutex for the given block hash and so that is done here.
func (*CfFilteredChainView) Start ¶
func (c *CfFilteredChainView) Start() error
Start kicks off the FilteredChainView implementation. This function must be called before any calls to UpdateFilter can be processed.
NOTE: This is part of the FilteredChainView interface.
func (*CfFilteredChainView) Stop ¶
func (c *CfFilteredChainView) Stop() error
Stop signals all active goroutines for a graceful shutdown.
NOTE: This is part of the FilteredChainView interface.
func (*CfFilteredChainView) UpdateFilter ¶
func (c *CfFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
UpdateFilter updates the UTXO filter which is to be consulted when creating FilteredBlocks to be sent to subscribed clients. This method is cumulative meaning repeated calls to this method should _expand_ the size of the UTXO sub-set currently being watched. If the set updateHeight is _lower_ than the best known height of the implementation, then the state should be rewound to ensure all relevant notifications are dispatched.
NOTE: This is part of the FilteredChainView interface.
type FilteredBlock ¶
type FilteredBlock struct { // Hash is the hash of the newly filtered block. Hash chainhash.Hash // Height is the height of the newly filtered block. Height uint32 // Transactions is the set of transactions which modify (spend) the // subscribed UTXO subset. Transactions []*wire.MsgTx }
FilteredBlock is a block which includes the transactions that modify the subscribed sub-set of the UTXO set registered to the current FilteredChainView concrete implementation.
type FilteredChainView ¶
type FilteredChainView interface { // FilteredBlocks returns the channel that filtered blocks are to be // sent over. Each time a block is connected to the end of a main // chain, and appropriate FilteredBlock which contains the transactions // which mutate our watched UTXO set is to be returned. In case of a // UpdateFilter call with an updateHeight lower than the current best // height, blocks with the updated filter will be resent, and must be // handled by the receiver as an update to an already known block, NOT // as a new block being connected to the chain. FilteredBlocks() <-chan *FilteredBlock // DisconnectedBlocks returns a receive only channel which will be sent // upon with the empty filtered blocks of blocks which are disconnected // from the main chain in the case of a re-org. // NOTE: In case of a reorg, connected blocks will not be available to // read from the FilteredBlocks() channel before all disconnected block // have been received. DisconnectedBlocks() <-chan *FilteredBlock // UpdateFilter updates the UTXO filter which is to be consulted when // creating FilteredBlocks to be sent to subscribed clients. This // method is cumulative meaning repeated calls to this method should // _expand_ the size of the UTXO sub-set currently being watched. If // the set updateHeight is _lower_ than the best known height of the // implementation, then the state should be rewound to ensure all // relevant notifications are dispatched, meaning blocks with a height // lower than the best known height might be sent over the // FilteredBlocks() channel. UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error // FilterBlock takes a block hash, and returns a FilteredBlocks which // is the result of applying the current registered UTXO sub-set on the // block corresponding to that block hash. // // TODO(roasbeef): make a version that does by height also? FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error) // Start starts all goroutine necessary for the operation of the // FilteredChainView implementation. Start() error // Stop stops all goroutines which we launched by the prior call to the // Start method. Stop() error }
FilteredChainView represents a subscription to a certain subset of the UTXO set for a particular chain. This interface is useful from the point of view of maintaining an up-to-date channel graph for the Lightning Network. The subset of the UTXO to be subscribed is that of all the currently opened channels. Each time a channel is closed (the output is spent), a notification is to be sent allowing the graph to be pruned.
NOTE: As FilteredBlocks are generated, it is recommended that implementations reclaim the space occupied by newly spent outputs.