doc(btc): uupdate func description

Co-authored-by: Gaze <dev@gaze.network>
This commit is contained in:
Gaze
2024-04-11 23:17:26 +07:00
parent 2c54dc9245
commit ea4bccffd7
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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