-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/localbridgesync #12
Conversation
case <-ctx.Done(): | ||
close(downloadedCh) | ||
return | ||
default: |
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.
Would it make sense to introduce the polling frequency parameter and use it here (namely declare some ticker here and periodically fetch and notify about the new blocks)?
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.
the idea is to don't have frequency, but rather go until the end (tip of the network) and if reached wait for new blocks
7caed89
to
a17868b
Compare
} | ||
|
||
func New(ctx context.Context) (*ReorgDetector, error) { | ||
r := &ReorgDetector{} |
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.
Reminder: don't forget to provide the ethclient.Client
reference through a constructor.
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.
Null pointer?
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.
The code is very simple and elegant!
Quality Gate failedFailed conditions |
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.
LGTM 🎩 aside from the reorgs comments
) | ||
|
||
var ( | ||
bridgeEventSignature = crypto.Keccak256Hash([]byte("BridgeEvent(uint8,uint32,address,uint32,address,uint256,bytes,uint32)")) |
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.
Aren't this declared on cdk-contracts-tooling repo?
} | ||
|
||
func New(ctx context.Context) (*ReorgDetector, error) { | ||
r := &ReorgDetector{} |
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.
Null pointer?
for currentBlock > lastBlockFromClient { | ||
lastBlockFromClient, err = r.ethClient.BlockNumber(ctx) | ||
if err != nil { | ||
// TODO: handle error |
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.
At least log?
} | ||
block, err := r.ethClient.HeaderByNumber(ctx, big.NewInt(int64(currentBlock))) | ||
if err != nil { | ||
// TODO: handle error |
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.
Log the err maybe?
Implementation of the
localbridgesyncer
. Please do not review thereorgdetector
as it's left as a PoC