Instance
These operations are specifically designed for use within instance handlers and are tailored to handle blockchain reorganisations (reorgs) automatically. When you're indexing blockchain data and writing to a reorg-aware database, InstanceDBOperations ensure that any reorgs are managed behind the scenes, eliminating the need for manual intervention. It's recommended to use these operations for all write operations within instance handler code, as they ensure the data remains consistent and reliable, even in the event of a reorg.
Operations
The Instance client in the Blockflow SDK provides two primary operations that are crucial for managing blockchain data with automatic reorg handling:
save The
save
operation is used to store data in your database. This function ensures that any blockchain data being indexed is saved reliably, with built-in reorg handling to maintain data integrity in case of blockchain reorganisations.load The
load
operation retrieves data from the database. It allows you to access previously stored blockchain data, ensuring that the data is reorg-aware and consistent with the current blockchain state.
How to Use
To use the Instance Client in combination with MongoClient, you can set it up as shown in the example below. This code maintains two databases:
One to store all
Transfer
events.Another to store sender information, the number of times a transfer was made from a given address.
Last updated