-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: chain watcher #47
Conversation
@@ -253,10 +254,7 @@ export class ChainContext { | |||
this.chainId = chainId; | |||
} | |||
|
|||
public static async create( | |||
storage: DBService, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my oppinion here the logic is inverted. The model should not receive a DB and persist itself. The model should expose plain data and the persistance layer persist it
Otherwise you couple the model to the persistance layer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a little strange as I show:
public static async create(url: string): Promise<ChainContext> {
const provider = new ethers.providers.JsonRpcProvider(url);
const chainId = (await provider.getNetwork()).chainId;
return new ChainContext(provider, apiUrl(chainId), chainId);
}
Around this function. Nonetheless, can be added in a later PR to get over the waterfall 🐃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked great
81cad59
to
aad11d7
Compare
Description
As we are removing Tenderly, we need to handle our own run loops for watching blocks / transaction logs.
Changes
warmUp
to initialise state from genesis, or last processed block.warmUp
warmUp
is complete, flag asinSync
, and commence block watching.ChainWatcher
, which runs per-chain, but we can handle many RPCsHow to test
No unit tests available, however can observe functionality, such as with:
NOTE: Substitute the above RPCs with the RPCs of your choice for the chains.
Observe synchronising of state. If Ctrl+C, observe
SIGINT
is caught, database is saved. Restart, and node resumes from last known synced block.Todo
Related Issues
Closes #46