Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix keypoolrefill perfomance and adjusted callback logic #1508

Merged
merged 4 commits into from
Jan 5, 2022

Conversation

k9ert
Copy link
Collaborator

@k9ert k9ert commented Dec 11, 2021

When a wallet is created, the keypoolrefill-function get called for each address of probably 50 addresses wasting lots of time to write a csv-file dozens of times. This fixes this behaviour (in wallet.py).

It also adjusts the behaviour of the SPECTER_PERSISTENCE_CALLBACK (or SPECTER_PERSISTENCE_CALLBACK_ASYNC for a script which would run in a thread) to make it more flexible. This env-var takes an executable which will get called any time the persistence-layer is modifying a file.
Example:

  • You have written a script called /usr/local/bin/my_rsync_script.sh
  • You specify that script like export SPECTER_PERSISTENCE_CALLBACK=/usr/local/bin/my_rsync_script.sh
  • In the past, that script simply get called
  • Now if gets additional parameters:
    • the mode which is either write or delete
    • the filepath
  • So an example-call would be /usr/local/bin/my_rsync_script.sh write /home/someuser/.specter/config.json
  • You can also specify it in the SPECTER_PERSISTENCE_CALLBACK_ASYNC and it'll be called in a thread.
    Those changes are in persistence.py.

Also this PR contains an autodetection-mechanism for Liquid-nodes. So in parallel to BTC_RPC_USER, BTC_RPC_PASSWORD, BTC_RPC_HOST, BTC_RPC_PORT, ELM_RPC_PROTOCOL we now also have ELM_RPC_USER, ELM_RPC_PASSWORD, ELM_RPC_HOST, ELM_RPC_PORT ELM_RPC_PROTOCOL.
This was a bit tricky as a node was, up to now, indifferent about the type (until it queried the RPC-interface). Now we need to specify the type of the node upfront in order to make the autodetection work if someone uses both autodetection-mechanisms at the same time.
Also, the NodeManager created an initial Node if there wasn't one. So we needed to adjust that and we create a second Liquid-Node if there isn't one (AND an env-var is existing). See the node_type as the first argument (which will then differ in which Env-vars to pick up):

            if os.environ.get("ELM_RPC_USER"):
                self.add_node(
                    node_type="ELM",
                    name="Blockstream Liquid",
                    autodetect=True,
                    datadir=get_default_datadir(node_type="ELM"),
                    user="",
                    password="",
                    port=7041,
                    host="localhost",
                    protocol="http",
                    external_node=True,
                    default_alias=self.DEFAULT_ALIAS,
                )
            self.add_node(
                node_type="BTC",
                name="Bitcoin Core",
                autodetect=True,
                datadir=get_default_datadir(),
                user="",
                password="",
                port=8332,
                host="localhost",
                protocol="http",
                external_node=True,
                default_alias=self.DEFAULT_ALIAS,

@netlify
Copy link

netlify bot commented Dec 11, 2021

✔️ Deploy Preview for specter-desktop-docs ready!

🔨 Explore the source changes: cdcd8c9

🔍 Inspect the deploy log: https://app.netlify.com/sites/specter-desktop-docs/deploys/61d5bdcac8f0860009c0f350

😎 Browse the preview: https://deploy-preview-1508--specter-desktop-docs.netlify.app

@moneymanolis moneymanolis self-requested a review December 30, 2021 13:42
Copy link
Collaborator

@moneymanolis moneymanolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@k9ert k9ert merged commit b12d0ef into cryptoadvance:master Jan 5, 2022
@k9ert k9ert deleted the storage_callback_fix branch January 27, 2023 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants