Skip to content

Commit

Permalink
Merge pull request #76 from evoskuil/version2
Browse files Browse the repository at this point in the history
Add mempool consistency configuration setting.
  • Loading branch information
evoskuil committed Dec 16, 2015
2 parents 587423a + 8ac8c64 commit c4b9df8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data/bn.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ checkpoint = 0000000000000000086672a8c97ad666f89cf04736951791150015419810d586:36
threads = 4
# The maximum number of transactions in the pool, defaults to 2000.
transaction_pool_capacity = 2000
# Enforce consistency between the pool and the blockchain, defaults to false.
transaction_pool_consistency = false
# Persistent host:port to augment discovered hosts, multiple entries allowed.
# peer = obelisk.airbitz.co:8333
# IP address to disallow as a peer, multiple entries allowed.
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/config/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct BCN_API settings
{
uint32_t threads;
uint32_t transaction_pool_capacity;
bool transaction_pool_consistency;
config::endpoint::list peers;
config::authority::list blacklists;
};
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/full_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace node {
// [node]
#define NODE_THREADS 4
#define NODE_TRANSACTION_POOL_CAPACITY 2000
#define NODE_TRANSACTION_POOL_CONSISTENCY false
#define NODE_PEERS {}
#define NODE_BLACKLISTS {}

Expand Down
4 changes: 3 additions & 1 deletion src/full_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const settings_type full_node::defaults
{
NODE_THREADS,
NODE_TRANSACTION_POOL_CAPACITY,
NODE_TRANSACTION_POOL_CONSISTENCY,
NODE_PEERS,
NODE_BLACKLISTS
},
Expand Down Expand Up @@ -181,7 +182,8 @@ full_node::full_node(const settings_type& config)
tx_pool_(
memory_threads_,
blockchain_,
config.node.transaction_pool_capacity),
config.node.transaction_pool_capacity,
config.node.transaction_pool_consistency),
tx_indexer_(
memory_threads_),
poller_(
Expand Down
2 changes: 2 additions & 0 deletions src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ bool inventory::handle_reorg(const std::error_code& ec, uint32_t fork_point,
BITCOIN_ASSERT((bc::max_uint32 - fork_point) >= new_blocks.size());
const auto height = static_cast<uint32_t>(fork_point + new_blocks.size());

// TODO: configure handshake with minimum_start_height so that it can
// disable relay from new peers until synced to the last checkpoint.
handshake_.set_start_height(height,
std::bind(&inventory::handle_set_height,
this, _1, height));
Expand Down
4 changes: 2 additions & 2 deletions test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(node_test__construct_getx_responder__does_not_throw)

threadpool threads;
blockchain_impl blockchain(threads, prefix);
transaction_pool transactions(threads, blockchain);
transaction_pool transactions(threads, blockchain, 2000, false);
responder responder(blockchain, transactions, 0);

blockchain.start();
Expand Down Expand Up @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(node_test__construct_session__does_not_throw)
handshake handshake(threads);
protocol protocol(threads, hosts, handshake, network);
blockchain_impl blockchain(threads, prefix);
transaction_pool transactions(threads, blockchain);
transaction_pool transactions(threads, blockchain, 2000, false);
poller poller(threads, blockchain);
responder responder(blockchain, transactions, 0);
inventory inventory(handshake, blockchain, transactions, 0);
Expand Down

0 comments on commit c4b9df8

Please sign in to comment.