Skip to content

Commit

Permalink
Implement UTXO tracking & double-spend protection
Browse files Browse the repository at this point in the history
The UtxoSet class uses a hash-map for its hot cache,
and an SQLite database for its cold store.

Outputs which are the coldest are periodically moved
from the hot cache to the cold store.

On shutdown, all the items are stored.
  • Loading branch information
AndrejMitrovic committed Sep 3, 2019
1 parent 93e9fda commit 1d535ec
Show file tree
Hide file tree
Showing 6 changed files with 674 additions and 71 deletions.
8 changes: 8 additions & 0 deletions source/agora/common/Config.d
Expand Up @@ -95,6 +95,9 @@ public struct NodeConfig
/// The seed to use for the keypair of this node
public immutable KeyPair key_pair;

/// Maximum number of UTXOs to keep in the hot cache (for performance)
public size_t utxo_cache_size = 4096;

/// Number of msecs to wait before retrying failed connections
public long retry_delay = 3000;

Expand Down Expand Up @@ -270,6 +273,10 @@ private NodeConfig parseNodeConfig (Node node)
auto max_listeners = node["max_listeners"].as!size_t;
auto address = node["address"].as!string;

size_t utxo_cache_size = NodeConfig.utxo_cache_size.init;
if (auto delay = "utxo_cache_size" in node)
utxo_cache_size = delay.as!size_t;

long retry_delay = 3000;
if (auto delay = "retry_delay" in node)
retry_delay = cast(long)(delay.as!float * 1000);
Expand All @@ -292,6 +299,7 @@ private NodeConfig parseNodeConfig (Node node)
port : port,
key_pair : key_pair,
retry_delay : retry_delay,
utxo_cache_size : utxo_cache_size,
max_retries : max_retries,
timeout : timeout,
data_dir : data_dir,
Expand Down

0 comments on commit 1d535ec

Please sign in to comment.