Skip to content

Commit

Permalink
feature(core): LIT-2560 - Refactor connect() logic
Browse files Browse the repository at this point in the history
- Ensure network sync is a mostly atomic operation - don't write node properties to client until handshakes complete
- Ensure multiple calls to the same core instance's `connect()` method are coalesced into one handshake operation
- Await operations inside of `connect()`, so that failures bubble up to the caller and they can react appropriately
- Refactor `listenForNewEpoch()` to track staking contract listener in a way that allows for disconnection later and ensure one-and-only-one listener is ever attached
- Add `disconnect()` method that clears all intervals to allow consumers to shut down gracefully
- Make `networkSyncInterval` explicitly private (use `disconnect()`!)
- Fix a variety of incorrect types
- Replace 500ms polling setInterval that compared length of `serverKeys` and `config.bootstrapUrls` with Promise.race() for timeout condition
- JSDocs and clearer context in error messages
  • Loading branch information
MaximusHaximus committed Mar 12, 2024
1 parent 17c6e2a commit 8a6f97b
Showing 1 changed file with 380 additions and 256 deletions.
Loading

0 comments on commit 8a6f97b

Please sign in to comment.