Configuration for this service can be found in the data\uaas.toml toml file.
The toml file is read when the service starts.
The toml configuration file is also used by the Python REST interface.
This document describes each element of the configuration file in the order that they are presented in the file.
[service]
user_agent = "/Bitcoin SV:1.0.9/"
network = "testnet"The `service section contains the following:
user_agentwhich provides the string that the service presents to the peer node on the network.networkwhich identifies the blockchain network that the service connects to, eithertestnetormainnet.
The network field determines the section of the configuration file that is read for the network settings (see next section).
There are two network settings sections testnet and mainnet, the network field in the service section determines which section is read.
This enables the service to be switched between the two networks without changing any of the settings for the other network.
[testnet]
ip = [ "176.9.148.163"]
port = 18333
start_block_hash = "000000000001f6f089b463c84c6509707db324f6f8e0c05324e856282c8b33d8"
start_block_height = 1485944
timeout_period = 240.0
startup_load_from_database = true
# Python database access
host = "host.docker.internal"
user = "uaas"
password = "uaas-password"
database = "uaas_db"
block_file = "../data/block.dat"
save_blocks = trueThe Network setting section contains the following fields:
ip- a list of the ip addresses of BSV nodes that the service will connect toport- the port that the service will connect to on the BSV node. This is typically set to8333for mainnet and18333for testnetstart_block_hash- identifies the first block that the service should work from the blockchain network. This allows the service to operate from a particular block rather that having to download all blocks since thes genesis blockstart_block_height- this is the heigh of thestart_block. This ensures that the REST API can return the correct block for a given block heighttimeout_period- the time thee service will wait without receiving messages from a peer before declaring the connectiontimed outstartup_load_from_database- makes the service load the data from the database on startup, this is the normal operation.
If this is set to false the service will load from the block file (see later), this is useful if the database structure is changed and we and want to repopulate the data without having to redownload all the blocks.
Note when reading from the file, would expect to delete the following tables: blocks, tx, utxo, mempool, Prior to starting the service.
block_file- identifies where the blocks are stored, used by both the Rust service and Python REST APIsave_blocks- when true the Rust service saves blocks to theblock_file, when false no blocks are saved.
host- the database hostuser- the database userpassword- the database passworddatabase- the database connection
Information used to configure the Rust database connection
[database]
mysql_url = "mysql://uaas:uaas-password@localhost:3306/uaas_db"
mysql_url_docker = "mysql://uaas:uaas-password@host.docker.internal:3306/uaas_db"
ms_delay = 300
retries = 6mysql_url- this is the url of the database, this is used by the Rust service on the local machinemysql_url_docker- asmysql_urlbut for use in a Docker containerms_delay- if a datase connection fails, this is the delay before retrying in milliseconds.retries- this is the number of times to retry a database connection before declaring the connection broken.
Settings regarding detecting orphan blocks.
[orphan]
detect = true
threshold = 100detect- when set totruethe service will look for orphan blocks. The service does not detect orphan blocks. However we have seen that when the hash of an unknown block is used as last known, header when requesting blocks, this results in the peer sending blocks from 2011. Typically prior to the first block the service has been configured to receive. When this happens the service will copy the block header to theorphantable and remove the block from theblockstable.threshold- is the number of blocks before we start looking for orphan blocks
This sets the logging messages level produced by the Rust service.
[logging]
level = "info"levelis the logging level.
The logging level can be one of:
"error"- Designates very serious errors."warn"- Designates hazardous situations."info"- Designates useful information."debug"- Designates useful information."trace"- Designates very low priority, often extremely verbose, information.
Collections are used to identify transactions that are of interest. The service can follow multiple Collections.
Note that each collection is defined in double square brackets [[]].
The following collection captures all Pay to Public Key Hash (P2PKH) transactions.
[[collection]]
name = "p2pkh"
locking_script_pattern = "76a914[0-9a-f]{40}88ac"
track_descendants = falseEach collection section has the following fields:
name- the name of the collection, the service will create a table with this name and store collection matching transaction in itlocking_script_pattern- a regular expression that identifies the locking script that defines the transactions of interesttrack_descendants- a flag to indicate if decendent transactions should also be captured.
This section identifies the address and port of the REST API.
[web_interface]
address = '127.0.0.1:5010'
log_level = 'info'
reload = falseIn the example above the REST API will be provided at http://127.0.0.1:5010/docs as a Swagger interface that the user can interact with.
The web interface section has the following fields:
address- this is the address and port that REST API will be provided onlog_level- this is the level that the REST API logs events atreload- if set to true the webserver will reload if the source code is changed