Categorygithub.com/onflow/flow-batch-scan
modulepackage
0.4.0
Repository: https://github.com/onflow/flow-batch-scan.git
Documentation: pkg.go.dev

# README

Flow Batch Scan

A library to make it easy to scan the entire flow chain.

How does it work

The BlockScanner.Scan method will perform a full scan of all the addresses on chain starting at the latest available block using the provided cadence script. This will take some time, during which the full scan has to switch newer reference blocks, because the old ones are no longer available. To ensure that the final data is accurate when the scan ends, an incremental scan also runs besides the full scan. The incremental scan looks at new blocks for any accounts could have had their data changed during that block (the data that the script is looking for). If there are candidates to be scanned, the incremental scanner will scan them with the same script and update the results of the full scan.

In continuous mode the incremental scan will keep running and will scan any candidates that might have changed.

The library expects 3 components:

  • a cadence script that has to accept an address array as input addresses: [Address] and returns any cadence value as the result.
  • an array of candidate scanners which scan a block range looking for accounts that could have had changed, so that the script would now return a different result.
  • a result handler that will be called with the results of the script for each address array.

Use case

Any quantity can be scanned for if:

  • it can be observed by a cadence script
  • the change of the quantity can be observed by looking at transaction results of a block (e.g: events)

Example:

  1. Scanning for contracts deployed on accounts. (see examples/contracts)
  2. Scanning for accounts FT or NFT balance.
  3. Scanning for public keys added to accounts.

Examples

See the examples folder, there are a lot of comments in there. The contract_names example is a one time scan example. the monitoer_contract_deployments example is a continuous scan example and builds on the contract_names example.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
InitAddressProvider uses bisection to get the last existing address.
No description provided by the author
NewComponentWithStart creates a new component with a start function.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewStatusReporter creates a new status reporter that reports the status of the indexer to prometheus.
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
DefaultIncrementalScannerMaxBlockGap is the maximum number of blocks that can scanned by the incremental scanner.
DefaultScriptRunnerMaxConcurrentScripts is the maximum number of scripts that can be running concurrently at any given time.
No description provided by the author
No description provided by the author

# Structs

AddressBatch is a batch of addresses that will be the input to the script being run byt the script runner at the given block height.
AddressProvider Is used to get all the addresses that exists at a certain referenceBlockId this relies on the fact that a certain `endOfAccountsError` will be returned by the `accountStorageUsageScript` if the address doesn't exist yet.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ProcessedAddressBatch contains the result of running the script on the given batch of addresses.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author