Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::testing::tester_network Class Reference

The tester_network class provides a simplistic virtual P2P network connecting testing_blockchains together. More...

#include <tester_network.hpp>

Public Member Functions

void connect_blockchain (base_tester &new_blockchain)
 Add a new blockchain to the network.
 
void disconnect_blockchain (base_tester &leaving_blockchain)
 Remove a blockchain from the network.
 
void disconnect_all ()
 Disconnect all blockchains from the network.
 
void propagate_block (const signed_block &block, const base_tester &skip_db)
 Send a block to all blockchains in this network.
 

Protected Attributes

std::map< base_tester *, scoped_connection > blockchains
 

Detailed Description

A tester may be connected to zero or more tester_networks at any given time. When a new tester joins the network, it will be synced with all other blockchains already in the network (blocks known only to the new chain will be pushed to the prior network members and vice versa, ignoring blocks not on the main fork). After this, whenever any blockchain in the network gets a new block, that block will be pushed to all other blockchains in the network as well.

Definition at line 19 of file tester_network.hpp.

Member Function Documentation

◆ connect_blockchain()

void sysio::testing::tester_network::connect_blockchain ( base_tester & new_blockchain)
Parameters
new_blockchainThe blockchain to add

TODO restore this

Definition at line 5 of file tester_network.cpp.

5 {
6 if (blockchains.count(&new_blockchain))
7 return;
8
9 // If the network isn't empty, sync the new blockchain with one of the old ones. The old ones are already in sync with
10 // each other, so just grab one arbitrarily. The old blockchains are connected to the propagation signals, so when one
11 // of them gets synced, it will propagate blocks to the others as well.
12 if (!blockchains.empty()) {
13 blockchains.begin()->first->sync_with(new_blockchain);
14 }
15
16 // The new blockchain is now in sync with any old ones; go ahead and connect the propagation signal.
17
19
20 /*
21 blockchains[&new_blockchain] = new_blockchain.control->applied_block.connect(
22 [this, &new_blockchain](const chain::block_trace& bt) {
23 propagate_block(bt.block, new_blockchain);
24 });
25 */
26 }
std::map< base_tester *, scoped_connection > blockchains

◆ disconnect_all()

void sysio::testing::tester_network::disconnect_all ( )

Definition at line 32 of file tester_network.cpp.

32 {
33 blockchains.clear();
34 }

◆ disconnect_blockchain()

void sysio::testing::tester_network::disconnect_blockchain ( base_tester & leaving_blockchain)
Parameters
leaving_blockchainThe blockchain to remove

Definition at line 28 of file tester_network.cpp.

28 {
29 blockchains.erase(&leaving_blockchain);
30 }

◆ propagate_block()

void sysio::testing::tester_network::propagate_block ( const signed_block & block,
const base_tester & skip_db )
Parameters
blockThe block to send

Definition at line 36 of file tester_network.cpp.

36 {
37 // for (const auto &pair : blockchains) {
38 // if (pair.first == &skip_blockchain) continue;
39 // boost::signals2::shared_connection_block blocker(pair.second);
40 // pair.first->control->push_block(block, sysio::chain::validation_steps::created_block);
41 // }
42 }

Member Data Documentation

◆ blockchains

std::map<base_tester *, scoped_connection> sysio::testing::tester_network::blockchains
protected

Definition at line 45 of file tester_network.hpp.


The documentation for this class was generated from the following files: