Skip to content
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: subscribe to bbn websocket new block events #32

Merged
merged 15 commits into from
Oct 30, 2024

Conversation

gusin13
Copy link
Collaborator

@gusin13 gusin13 commented Oct 25, 2024

This PR

  1. Sets up websocket and subs to new block events from bbn
  2. Heights are pushed to a channel which the bootstrap process is listening
  3. Lastprocessedheight is stored in db now, reboostrapping will start from the last fetched from db.

@gusin13 gusin13 marked this pull request as ready for review October 25, 2024 21:52
var result model.LastProcessedHeight
err := db.client.Database(db.dbName).
Collection(model.LastProcessedHeightCollection).
FindOne(ctx, bson.M{}).Decode(&result)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to make the collection generic for storing pointers so that this collection can be used for both BTC and BBN heights. (even for any other pointer values)
So it probably make sense to have a hardcoded primary key for the BBN height

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, is it ok if we change in later pr when the requirement arises?

btw in what case would we store btc pointer?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial plan for syncing withdrawal transactions was to perform the same block scan as BBN blocks by storing the BTC height as a pointer to track the last processed height, avoiding the need to sync historical data. However, since the decision has been made to use this library to subscribe to BTC transaction events, this approach is no longer necessary.

That said, I would still argue for keeping this table generic, allowing us to store any pointer in this collection for future use.

Yes, of course. feel free to raise a ticket and we can track it in later PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see sg, have made a ticket to track
#35

Copy link
Collaborator

@jrwbabylonlab jrwbabylonlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with some comments

@gusin13 gusin13 merged commit 2b6e1c6 into main Oct 30, 2024
11 checks passed
@gusin13 gusin13 deleted the gusin13/sub-bbn-events branch October 30, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants