mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-04-27 17:25:15 +08:00
doc(btc): uupdate func description
Co-authored-by: Gaze <dev@gaze.network>
This commit is contained in:
@@ -14,6 +14,10 @@ var _ indexers.BitcoinDatasource = (*BitcoinNodeDatasource)(nil)
|
||||
// BitcoinNodeDatasource fetch data from Bitcoin node for Bitcoin Indexer
|
||||
type BitcoinNodeDatasource struct{}
|
||||
|
||||
// Fetch polling blocks from Bitcoin node
|
||||
//
|
||||
// - from: block height to start fetching, if -1, it will start from genesis block
|
||||
// - to: block height to stop fetching, if -1, it will fetch until the latest block
|
||||
func (d *BitcoinNodeDatasource) Fetch(ctx context.Context, from, to int64) ([]*types.Block, error) {
|
||||
ch, stop, err := d.FetchAsync(ctx, from, to)
|
||||
if err != nil {
|
||||
@@ -35,6 +39,10 @@ func (d *BitcoinNodeDatasource) Fetch(ctx context.Context, from, to int64) ([]*t
|
||||
}
|
||||
}
|
||||
|
||||
// FetchAsync polling blocks from Bitcoin node asynchronously (non-blocking)
|
||||
//
|
||||
// - from: block height to start fetching, if -1, it will start from genesis block
|
||||
// - to: block height to stop fetching, if -1, it will fetch until the latest block
|
||||
func (d *BitcoinNodeDatasource) FetchAsync(ctx context.Context, from, to int64) (<-chan []*types.Block, func(), error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
_ = ctx
|
||||
|
||||
@@ -22,7 +22,7 @@ type (
|
||||
// Make sure to implement the IndexerWorker interface
|
||||
var _ core.IndexerWorker = (*BitcoinIndexer)(nil)
|
||||
|
||||
// BitcoinIndexer is the indexer for sync Bitcoin data to the database.
|
||||
// BitcoinIndexer is the polling indexer for sync Bitcoin data to the database.
|
||||
type BitcoinIndexer struct {
|
||||
Processor BitcoinProcessor
|
||||
Datasource BitcoinDatasource
|
||||
|
||||
Reference in New Issue
Block a user