node
node copied to clipboard
EthereumRegistryWriter: onCidAdded restart resiliency
Currently if EthereumRegistryWriter is restarted after an addCid
transaction has been sent to geth but before the associated cidAdded
event is picked up, that event will never be picked up, since EthereumRegistryWriter always starts listening to cidAdded
events from the latest block geth has seen.
This can be solved by indexing onCidAdded.blockNumber
in the db, pick up the highest onCidAdded.blockNumber
on startup and passing that to fromBlock
.
const fromBlock = await db. // some aggregate `sum` function or sort by and findOne
const onCidAddedPromievent = await ethereumRegistryContract.onCidAdded({ fromBlock }, handleEventError)
The chances of this happening are probably slim so not the highest priority at the moment.