Skip to content

Commit 5cfac72

Browse files
committed
Expose electrum options to protocol and channel.
1 parent 0d75298 commit 5cfac72

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

include/bitcoin/server/channels/channel_electrum.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ class BCS_API channel_electrum
3939
public:
4040
typedef std::shared_ptr<channel_electrum> ptr;
4141
using interface_t = interface::electrum;
42-
using options_t = typename network::channel_rpc<interface_t>::options_t;
42+
using options_t = settings::electrum_server;
4343

4444
inline channel_electrum(const network::logger& log,
4545
const network::socket::ptr& socket, uint64_t identifier,
4646
const node::configuration& config, const options_t& options) NOEXCEPT
4747
: server::channel(log, socket, identifier, config),
48+
options_(options),
4849
network::channel_rpc<interface::electrum>(log, socket, identifier,
4950
config.network, options),
5051
network::tracker<channel_electrum>(log)
@@ -74,7 +75,15 @@ class BCS_API channel_electrum
7475
return version_;
7576
}
7677

78+
inline const options_t& options() const NOEXCEPT
79+
{
80+
return options_;
81+
}
82+
7783
private:
84+
// This is thread safe.
85+
const options_t& options_;
86+
7887
// These are protected by strand.
7988
electrum::version version_{ electrum::version::v0_0 };
8089
std::string name_{};

include/bitcoin/server/protocols/protocol_electrum.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class BCS_API protocol_electrum
4242
const network::channel::ptr& channel,
4343
const options_t& options) NOEXCEPT
4444
: protocol_rpc<channel_electrum>(session, channel, options),
45+
options_(options),
4546
channel_(std::dynamic_pointer_cast<channel_t>(channel)),
4647
network::tracker<protocol_electrum>(session->log)
4748
{
@@ -132,7 +133,15 @@ class BCS_API protocol_electrum
132133
return channel_->version() >= version;
133134
}
134135

136+
inline const options_t& options() const NOEXCEPT
137+
{
138+
return options_;
139+
}
140+
135141
private:
142+
// This is thread safe.
143+
const options_t& options_;
144+
136145
// This is mostly thread safe, and used in a thread safe manner.
137146
const channel_t::ptr channel_;
138147
};

include/bitcoin/server/protocols/protocol_electrum_version.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class BCS_API protocol_electrum_version
4141
const network::channel::ptr& channel,
4242
const options_t& options) NOEXCEPT
4343
: protocol_rpc<channel_electrum>(session, channel, options),
44+
options_(options),
4445
channel_(std::dynamic_pointer_cast<channel_t>(channel)),
4546
network::tracker<protocol_electrum_version>(session->log)
4647
{
@@ -69,7 +70,15 @@ class BCS_API protocol_electrum_version
6970
std::string escape_client(const std::string& in) NOEXCEPT;
7071
bool set_client(const std::string& name) NOEXCEPT;
7172

73+
inline const options_t& options() const NOEXCEPT
74+
{
75+
return options_;
76+
}
77+
7278
private:
79+
// This is thread safe.
80+
const options_t& options_;
81+
7382
// This is mostly thread safe, and used in a thread safe manner.
7483
const channel_t::ptr channel_;
7584

0 commit comments

Comments
 (0)