AegeusCoin / aegeus-ui

0 stars 2 forks source link

Modify import address call for speed and efficiency #33

Open AegeusCoin opened 5 years ago

AegeusCoin commented 5 years ago

Currently a call to importaddress can take upwards of 30 seconds to complete. This is due to scanning the entire blockchain for registrations by other users. The blockchain as it stands is nearly 400k blocks and this portal is not live yet. As such there is no reason to scan the entire chain, it is a waste of time. I've modified the Aegeus RPC call, that when a value of true is called with it as a parameter it will only scan after a specific block height (once this is live). The result is a mere fraction of a second return time. If approved I will push my changes to the aegeus repo and we can then rebuild all images involved based on that.

tdiesler commented 5 years ago

Ok, please reference the associated aegeus issue here. How would that play with address/file registration discovery?

AegeusCoin commented 5 years ago

https://github.com/AegeusCoin/aegeus/issues/20 is the related issue. Addresses registered through the prototype, would have had no means of registration prior. With that considered, it would result in a much quicker execution and response time when scanning from logical starting height and pose no risk of error or data exclusion.

AegeusCoin commented 5 years ago

This modification to the core wallet has been completed and tested. The associated PR can be found at: https://github.com/AegeusCoin/aegeus/pull/21

tdiesler commented 5 years ago

Nessus-1.0.0.Beta2 addresses this issue in the layer above the wallet (i.e. the WebUI) by asynch import like this

lastJob = executorService.submit(new Callable<Address>() {

            @Override
            public Address call() throws Exception {
                if (wallet.isP2PKH(key)) {
                    LOG.info("Importing watch only address: {}", key);
                    return wallet.importAddress(key, Arrays.asList(label));
                } else {
                    LOG.info("Importing private key: P**************");
                    return wallet.importPrivateKey(key, Arrays.asList(label));
                }
            }
        });

also, potential errors in asynch ops are reported like this

       // Check the status of our last asynch job
        if (lastJob != null) {
            if (lastJob.isDone()) {
                try {
                    Address addr = lastJob.get();
                    LOG.info("Successfully imported: " + addr);
                } finally {
                    lastJob = null;
                }
            } else {
                LOG.info("Last import job still running ...");
            }
        }

The wallet still does a full rescan in the background.

AegeusCoin commented 5 years ago

While this resolves the issue of needing to wait for a response, I'd imagine it doesn't knock any time off of the operation's execution/response time. For the purposes of demonstration the code I've pushed to the main repo resolves this immediate issue - but long-term use we will end up back at the same position. The only true solution is creating a more efficient meants of key registration/discovery. If you're happy with results post-modification - we can close this.

tdiesler commented 5 years ago

Not blocked by changes to the wallet code any more. After an update to nessus-1.0.0.Beta2 this can be fixed in the WebUI