Skip to content

Commit 70948c2

Browse files
committed
Refactor config and channel construct for network consistency.
1 parent 334f44f commit 70948c2

File tree

15 files changed

+97
-75
lines changed

15 files changed

+97
-75
lines changed

include/bitcoin/node/channels/channel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class BCN_API channel
3636
DELETE_COPY_MOVE_DESTRUCT(channel);
3737

3838
protected:
39-
channel(const network::logger&, const network::socket::ptr&,
40-
const node::configuration&, uint64_t=zero) NOEXCEPT
39+
channel(const network::logger&, const network::socket::ptr&, uint64_t,
40+
const node::configuration&) NOEXCEPT
4141
{
4242
}
4343
};

include/bitcoin/node/channels/channel_http.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ class BCN_API channel_http
3434
{
3535
public:
3636
typedef std::shared_ptr<node::channel_http> ptr;
37-
using options_t = network::channel_http::options_t;
3837

39-
channel_http(const network::logger& log, const network::socket::ptr& socket,
40-
const node::configuration& config, uint64_t identifier=zero,
41-
const options_t& options={}) NOEXCEPT
42-
: network::channel_http(log, socket, config.network, identifier, options),
43-
node::channel(log, socket, config, identifier)
38+
channel_http(const network::logger& log,
39+
const network::socket::ptr& socket, uint64_t identifier,
40+
const node::configuration& config, const options_t& options) NOEXCEPT
41+
: network::channel_http(log, socket, identifier, config.network, options),
42+
node::channel(log, socket, identifier, config)
4443
{
4544
}
4645
};

include/bitcoin/node/channels/channel_peer.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ class BCN_API channel_peer
3535
public:
3636
typedef std::shared_ptr<node::channel_peer> ptr;
3737

38-
channel_peer(network::memory& memory, const network::logger& log,
39-
const network::socket::ptr& socket, const node::configuration& config,
40-
uint64_t identifier=zero) NOEXCEPT
41-
: network::channel_peer(memory, log, socket, config.network, identifier),
42-
node::channel(log, socket, config, identifier),
38+
channel_peer(network::memory& allocator, const network::logger& log,
39+
const network::socket::ptr& socket, uint64_t identifier,
40+
const node::configuration& config, const options_t& options) NOEXCEPT
41+
: network::channel_peer(allocator, log, socket, identifier,
42+
config.network, options),
43+
node::channel(log, socket, identifier, config),
4344
announced_(config.node.announcement_cache)
4445
{
4546
}

include/bitcoin/node/channels/channel_tcp.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ class BCN_API channel_tcp
3434
{
3535
public:
3636
typedef std::shared_ptr<node::channel_tcp> ptr;
37-
using options_t = network::channel_tcp::options_t;
3837

3938
channel_tcp(const network::logger& log, const network::socket::ptr& socket,
40-
const node::configuration& config, uint64_t identifier=zero,
41-
const options_t& options={}) NOEXCEPT
42-
: network::channel_tcp(log, socket, config.network, identifier, options),
43-
node::channel(log, socket, config, identifier)
39+
uint64_t identifier, const node::configuration& config,
40+
const options_t& options) NOEXCEPT
41+
: network::channel_tcp(log, socket, identifier, config.network, options),
42+
node::channel(log, socket, identifier, config)
4443
{
4544
}
4645
};

include/bitcoin/node/channels/channel_ws.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@ class BCN_API channel_ws
3535
{
3636
public:
3737
typedef std::shared_ptr<node::channel_ws> ptr;
38-
using options_t = network::channel_ws::options_t;
3938

40-
channel_ws(const network::logger& log,
41-
const network::socket::ptr& socket,
42-
const node::configuration& config, uint64_t identifier=zero,
43-
const options_t& options={}) NOEXCEPT
44-
: network::channel_ws(log, socket, config.network, identifier,
45-
options),
46-
node::channel(log, socket, config, identifier)
39+
channel_ws(const network::logger& log, const network::socket::ptr& socket,
40+
uint64_t identifier, const node::configuration& config,
41+
const options_t& options) NOEXCEPT
42+
: network::channel_ws(log, socket, identifier, config.network, options),
43+
node::channel(log, socket, identifier, config)
4744
{
4845
}
4946
};

include/bitcoin/node/chase.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ enum class chase
6161
/// Issued by 'session_outbound' and handled by 'block_in_31800'.
6262
split,
6363

64-
/// Channels (all with work) directed to split work and stop (channel_t).
64+
/// Channels (all with work) directed to split work and stop (peer_t).
6565
/// Issued by 'session_outbound' and handled by 'block_in_31800'.
6666
stall,
6767

68-
/// Channels (all with work) directed to drop work and stop (channel_t).
68+
/// Channels (all with work) directed to drop work and stop (peer_t).
6969
/// Issued by 'check' and handled by 'block_in_31800'.
7070
purge,
7171

include/bitcoin/node/define.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ using object_key = uint64_t;
7070
/// Event value types.
7171
using count_t = size_t;
7272
using height_t = size_t;
73-
using channel_t = uint64_t;
73+
using peer_t = uint64_t;
7474
using object_t = object_key;
7575
using header_t = database::header_link::integer;
7676
using transaction_t = database::tx_link::integer;

include/bitcoin/node/protocols/protocol_block_in_31800.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class BCN_API protocol_block_in_31800
6565

6666
/// Manage work splitting.
6767
bool is_idle() const NOEXCEPT override;
68-
virtual void do_purge(channel_t) NOEXCEPT;
69-
virtual void do_split(channel_t) NOEXCEPT;
68+
virtual void do_purge(peer_t) NOEXCEPT;
69+
virtual void do_split(peer_t) NOEXCEPT;
7070
virtual void do_report(count_t count) NOEXCEPT;
7171

7272
/// Check incoming block message.

include/bitcoin/node/protocols/protocol_peer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class BCN_API protocol_peer
3535
: public network::protocol_peer,
3636
public node::protocol
3737
{
38+
public:
39+
// Replace base class channel_t (network::channel_peer).
40+
using channel_t = node::channel_peer;
41+
3842
protected:
3943
/// Constructors.
4044
/// -----------------------------------------------------------------------

include/bitcoin/node/sessions/session_peer.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <memory>
2323
#include <utility>
24-
#include <bitcoin/node/channels/channel.hpp>
24+
#include <bitcoin/node/channels/channels.hpp>
2525
#include <bitcoin/node/define.hpp>
2626
#include <bitcoin/node/protocols/protocols.hpp>
2727
#include <bitcoin/node/sessions/session.hpp>
@@ -39,6 +39,7 @@ class session_peer
3939
{
4040
public:
4141
typedef std::shared_ptr<session_peer<Session>> ptr;
42+
using options_t = network::settings::tcp_server;
4243
using channel_t = node::channel_peer;
4344

4445
/// Construct an instance.
@@ -59,9 +60,10 @@ class session_peer
5960
{
6061
BC_ASSERT(this->stranded());
6162

63+
// TODO: send options_t.
6264
const auto channel = std::make_shared<channel_t>(
63-
this->get_memory(), this->log, socket, this->config(),
64-
this->create_key());
65+
this->get_memory(), this->log, socket, this->create_key(),
66+
this->config(), options_t{});
6567

6668
return std::static_pointer_cast<network::channel>(channel);
6769
}

0 commit comments

Comments
 (0)