cculianu / Fulcrum

A fast & nimble SPV Server for BCH, BTC, and LTC
Other
349 stars 79 forks source link

Bind admin port for listening during synchronization #263

Open nmfretz opened 1 week ago

nmfretz commented 1 week ago

As long as the server is still synchronizing, all public-facing ports will not yet be bound for listening and as such an attempt to connect to one of the RPC ports will fail with a socket error such as e.g. "Connection refused". Once the server finishes synching it will behave like an ElectronX/ElectrumX server and it can receive requests from Electron Cash (or Electrum if on BTC).

It would be super useful to allow connections on the admin port during synchronization. I understand the reasoning for not accepting connections on a public TCP port (e.g., 50001) before sync completes (e.g., only want to serve clients correct info), but enabling access to the admin port would allow, say, a UI dashboard to easily monitor sync progress and provide real-time updates to users.

As an example, we have an ElectrumX app on the app store for umbrelOS, where users can see real-time sync progress via an rpc port that listens on startup, before the public tcp port is listening:

image

ElectrumX starts listening on rpc port 8000 right away, and then only listens on tcp ports once sync is complete.

But for Fulcrum, the admin port doesn't start listening until synchronization is complete, so you can't query something like getinfo from the admin port to get version and sync details until after fulcrum is 100% synced.

[2024-11-14 23:57:25.746] <Controller> Processed height: 870000, 100.0%, 41.8 blocks/min, 2475.9 txs/sec, 6066.4 addrs/sec
[2024-11-15 00:02:03.308] <Controller> Processed 1573 new blocks with 5642482 txs (12634254 inputs, 14576066 outputs, 13697765 addresses), verified ok.
[2024-11-15 00:02:03.309] <Controller> Block height 870328, downloading new blocks ...
[2024-11-15 00:02:07.587] <Controller> Processed 5 new blocks with 17540 txs (38612 inputs, 54936 outputs, 63322 addresses), verified ok.
[2024-11-15 00:02:07.588] <Controller> Block height 870328, up-to-date
[2024-11-15 00:02:07.589] SrvMgr: starting 2 services ...
[2024-11-15 00:02:07.589] Starting listener service for TcpSrv 0.0.0.0:50002 ...
[2024-11-15 00:02:07.590] Service started, listening for connections on 0.0.0.0:50002
[2024-11-15 00:02:07.590] Starting listener service for AdminSrv 0.0.0.0:8000 ...
[2024-11-15 00:02:07.590] Service started, listening for connections on 0.0.0.0:8000

So we're kinda stuck showing something like this until Fulcrum is 100% synced, which isn't super useful:

image

@cculianu would this be something you'd be okay with implementing?

SeafireGit commented 6 days ago

+1, it would be super handy to be able to follow sync progress from admin script instead of logfiles.