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

213 conf persistence #214

Merged
merged 4 commits into from
Aug 29, 2022
Merged

213 conf persistence #214

merged 4 commits into from
Aug 29, 2022

Conversation

0xp3gasus
Copy link
Collaborator

Description

Configuration persistence. If Connector is restarted for any reason, it will reload the currencies configuration from a backup file.

Fixes #213 (issue)

Dependencies (if any)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Nodechain running for eth in testnet network

    python3 nodechain.py -t eth -n testnet -p 80 -sp 443 -b /path/to/blockchains/testnet start
  • Getting default configuration

    curl --location --request POST 'http://localhost:80/admin/getcoin' \
    --header 'x-api-key: API_KEY_VALUE' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "coin": "eth",
        "network": "testnet"
    }'
    {
        "success": true,
        "message": "Configuration for testnet network for currency eth retrieved successfully",
        "coin": "eth",
        "network": "testnet",
        "config": {
           "rpcEndpoint": "http://ethereumgo-testnet:8545",
           "wsEndpoint": "ws://ethereumgo-testnet:8546",
           "indexerEndpoint": "http://postgrest-testnet:3000"
        }
    }
  • Config for eth in testnet network updated successfully

    curl --location --request POST 'http://localhost:80/admin/updatecoin' \
    --header 'x-api-key: API_KEY_VALUE' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "coin": "eth",
        "network": "testnet",
        "config": {
            "rpcEndpoint": "http://another-ethereumgo-testnet:8545",
            "wsEndpoint": "ws://another-ethereumgo-testnet:8546",
            "indexerEndpoint": "http://another-postgrest-testnet:3000"
        }
    }'
     {
        "success": true,
        "message": "Configuration for testnet network for currency eth updated successfully"
    }
  • Connector is restarted

    docker restart connector_connector_1
  • Getting config for eth in testnet network

    curl --location --request POST 'http://localhost:80/admin/getcoin' \
    --header 'x-api-key: API_KEY_VALUE' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "coin": "eth",
        "network": "testnet"
    }'
    {
        "success": true,
        "message": "Configuration for testnet network for currency eth retrieved successfully",
        "coin": "eth",
        "network": "testnet",
        "config": {
            "rpcEndpoint": "http://another-ethereumgo-testnet:8545",
            "wsEndpoint": "ws://another-ethereumgo-testnet:8546",
            "indexerEndpoint": "http://another-postgrest-testnet:3000"
        }
    }

Test Configuration:

  • Operating system (output of sw_vers): macOS 12.5
  • Kernel version (output of uname -sr): Darwin 21.6.0
  • Architecture (output of uname -m): x86_6

Good practices to consider

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@0xp3gasus 0xp3gasus self-assigned this Aug 18, 2022
@bridgedragon
Copy link
Collaborator

  • Functions and files shouldn't be called 'backup' because Nodechain is not backing up anything. Instead, it is persisting the configuration. So, we should replace 'backup' word in the code with 'persistent configuration'. The file should be named something like 'config.json'.
  • Docker-composes should be configured with the configuration file inside a volume.

@bridgedragon bridgedragon merged commit 4430845 into swapper-org:staging Aug 29, 2022
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.

Add persistence to currency configurations
2 participants