Page MenuHomePhabricator

[alias-server] Better handling of startup case
AbandonedPublic

Authored by bytesofman on Mar 31 2023, 14:00.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Summary

T3060

Depends on D13521

Improve how the case of app startup is handled. We want to run the same loop as 'BlockConnected' for this case, but it needs slightly different logic (i.e. you don't start with a blockhash to check with avalanche).

This diff provides the isAppStartup boolean which will be used to control later logic in the existing loop.

Test Plan

node index.js
Check console for Checking for new aliases on startup

Diff Detail

Repository
rABC Bitcoin ABC
Branch
rpc-avalanche-check
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22873
Build 45366: Build Diffalias-server-tests
Build 45365: arc lint + arc unit

Event Timeline

better log statement for startup

emack requested changes to this revision.Apr 1 2023, 00:57
emack added a subscriber: emack.
emack added inline comments.
web/alias-server/src/websocket.js
42

needs a break; here

This revision now requires changes to proceed.Apr 1 2023, 00:57
bytesofman added inline comments.
web/alias-server/src/websocket.js
42

looked weird to me too, but apparently this is the standard way to handle "the same thing happens for these two cases" in a switch loop: you intentionally create a fall-through by omitting break.

examples:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
https://stackoverflow.com/questions/16706716/using-two-values-for-one-switch-case-statement

So, in this case, we are saying "run this loop if you are first starting up the app OR if chronik has announced a new blockhash"

This revision is now accepted and ready to land.Apr 1 2023, 01:31
Fabien added inline comments.
web/alias-server/src/websocket.js
37 ↗(On Diff #39156)

In the light of the feedback from D13523 this belongs to the switch.
What is the value of wsMsg.blockHash upon startup ?

web/alias-server/src/websocket.js
37 ↗(On Diff #39156)

wsMsg.blockHash will be undefined on startup.

In light of the refactoring done on D13523, this commit could be dropped. I don't think it's worth refactoring to support D13523. This is just asking for a rebase conflict.

To be rebuilt after other diffs