cryptoadvance / spectrum

Electrum adaptor simulating Bitcoin RPC protocol
MIT License
8 stars 11 forks source link

Feature: User Feedback for not synced nodes and DBs #38

Closed k9ert closed 1 year ago

k9ert commented 1 year ago

One of the main reasons specter doesn't show the correct amounts is a not-synced node. For Spectrum, this might also be the case but there is another reason on top: Spectrum just booted up and connected to the electrum server but have not yet sunscribed to all the scripthashes it needs to. A scripthash is basically an address and this looks like this in the log:

[2023-01-23 12:07:39,618] INFO in spectrum: Now subscribed to 2900 scripthashes
[2023-01-23 12:07:44,015] INFO in spectrum: Now subscribed to 3000 scripthashes
[2023-01-23 12:07:49,189] INFO in spectrum: Now subscribed to 3100 scripthashes
[2023-01-23 12:07:53,949] INFO in spectrum: Now subscribed to 3200 scripthashes
...

Potentially, this could be shown as a percentage in the logs as the potential scripthashes are all in the DB. Simplified code from spectrum.py sync-method:

        for sc in Script.query.all():
            # ignore external scripts (labeled recepients)
            if sc.index is None:
                continue
            subscription_logging_counter += 1
            if subscription_logging_counter % 100 == 0:
                logger.info(
                    f"Now subscribed to {subscription_logging_counter} scripthashes"
                )
            res = self.sock.call("blockchain.scripthash.subscribe", [sc.scripthash])
            if res != sc.state:
                self.sync_script(sc, res)

So unless this loop is finished, specter might be outdated. This should clearly be reflexted in the UI. The current way of showing that looks like this: image If you click on the node, you get some details of that node which currently looks like this: image This is not optimal. I think it could be shown how much blocks are still too sync but both of the screenshots don't show that.

Anyway, this is about spectrum. Here, we don't have the warning, but you can only see the blockcount of the electrum-server: image

So in order to give better feedback:

So how should that be implemented? I would suggest the following:

k9ert commented 1 year ago

This is now basically solved with #40 so i'll close that here. However, @moritzwietersheim already mentioned that the user-feedback if he needs to wait for anything should be better. This is to some sort also a problem with leaky abstraction or the lack of it. It's an advantage to act as it would be Bitcoin Core Node but it's also a disadvantage if you're aware that it's not and you want to have implementation specific information like:

@moritzwietersheim : I don't think we can male reasoanbe progress on that end before we have a design idea how the user-feddback should look like.