Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 87 additions & 87 deletions console/embedded/admin_ecma.cpp

Large diffs are not rendered by default.

188 changes: 94 additions & 94 deletions console/embedded/native_ecma.cpp

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions console/executor_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ const std::unordered_map<uint8_t, std::string> executor::fired_
{ events::silent_secs, "silent_secs........." },
{ events::validate_usecs, "validate_usecs......" },

{ events::pool_submit_usecs, "pool_submit_usecs..." },
{ events::pool_coverage_usecs, "pool_coverage_usecs." },
{ events::pool_connect_usecs, "pool_connect_usecs.." },
{ events::pool_admit_usecs, "pool_admit_usecs...." },
{ events::pool_compact_usecs, "pool_compact_usecs.." },
{ events::pool_block_in_usecs, "pool_block_in_usecs." },
{ events::pool_block_out_usecs, "pool_block_out_usecs" },
{ events::pool_context_usecs, "pool_context_usecs.." },
{ events::pool_template_usecs, "pool_template_usecs." },
{ events::pool_project_usecs, "pool_project_usecs.." },

{ events::tx_dropped, "tx_dropped.........." },

{ events::unknown, "unknown............." }
};

Expand Down
13 changes: 13 additions & 0 deletions console/executor_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ code executor::open_store_coded(bool details)
return metadata_.stored_code;
}

// The pool compaction is the open's only pruning, and its last step.
std::optional<logger::time> compacting{};
////logger(BS_DATABASE_STARTING);
if (const auto ec = store_.open([&](auto event_, auto table)
{
if (!compacting && event_ == database::event_t::prune_table)
compacting = logger::now();

if (details)
logger(std::format(BS_OPEN,
server_node::store::events.at(event_),
Expand All @@ -143,6 +148,14 @@ code executor::open_store_coded(bool details)
return ec;
}

if (compacting)
{
const auto span = duration_cast<milliseconds>(logger::now() -
compacting.value());
logger(std::format(BS_POOL_COMPACTED, query_.pool_records(),
span.count()));
}

apply_envelope();
logger(BS_DATABASE_STARTED);
return error::success;
Expand Down
2 changes: 2 additions & 0 deletions console/localize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@
"Press CTRL-C to stop the node."
#define BS_DATABASE_STARTED \
"Database is started."
#define BS_POOL_COMPACTED \
"Pool compacted to ({}) rows in ({}) ms."
#define BS_NETWORK_STARTING \
"Please wait while network is starting..."
#define BS_NODE_START_FAIL \
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/server/interfaces/bitcoind_mining.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct bitcoind_mining_methods
method<"getmininginfo">{},
method<"submitblock", string_t, nullopt<""_t>, command>{ "hexdata", "dummy" },
method<"submitheader", string_t, command>{ "hexdata" },
method<"getblocktemplate", object_t>{ unimplemented, "template_request" },
method<"getblocktemplate", object_t>{ "template_request" },
method<"getprioritisedtransactions">{ unimplemented },
method<"prioritisetransaction", string_t, nullable<number_t>, nullopt<0.0>>{ unimplemented, "txid", "dummy", "fee_delta" }
};
Expand Down
18 changes: 9 additions & 9 deletions include/bitcoin/server/interfaces/native.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ struct native_methods
method<"top", uint8_t, uint8_t>{ "version", "media" },
method<"top_subscribe", uint8_t, uint8_t, optional<false>>{ "version", "media", "stop" },

method<"block", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<true>>{ "version", "media", "hash", "height", "witness" },
method<"block_header", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "hash", "height" },
method<"block_header_context", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "hash", "height" },
method<"block_details", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "hash", "height" },
method<"block_txs", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "hash", "height" },
method<"block_filter", uint8_t, uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "type", "hash", "height" },
method<"block_filter_hash", uint8_t, uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "type", "hash", "height" },
method<"block_filter_header", uint8_t, uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>>{ "version", "media", "type", "hash", "height" },
method<"block_tx", uint8_t, uint8_t, uint32_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<true>>{ "version", "media", "position", "hash", "height", "witness" },
method<"block", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<true>, optional<false>>{ "version", "media", "hash", "height", "witness", "candidate" },
method<"block_header", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "hash", "height", "candidate" },
method<"block_header_context", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "hash", "height", "candidate" },
method<"block_details", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "hash", "height", "candidate" },
method<"block_txs", uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "hash", "height", "candidate" },
method<"block_filter", uint8_t, uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "type", "hash", "height", "candidate" },
method<"block_filter_hash", uint8_t, uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "type", "hash", "height", "candidate" },
method<"block_filter_header", uint8_t, uint8_t, uint8_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<false>>{ "version", "media", "type", "hash", "height", "candidate" },
method<"block_tx", uint8_t, uint8_t, uint32_t, nullable<system::hash_cptr>, nullable<uint32_t>, optional<true>, optional<false>>{ "version", "media", "position", "hash", "height", "witness", "candidate" },
method<"block_subscribe", uint8_t, uint8_t, optional<false>>{ "version", "media", "stop" },

method<"tx", uint8_t, uint8_t, system::hash_cptr, optional<true>>{ "version", "media", "hash", "witness" },
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/server/parsers/native_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace native
constexpr auto turbo = "turbo";
constexpr auto format = "format";
constexpr auto witness = "witness";
constexpr auto candidate = "candidate";

/// Boolean values.
constexpr auto true_ = "true";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class BCS_API protocol_bitcoind_mining
bool handle_submit_header(const code& ec,
rpc_interface::submit_header, const std::string& hexdata) NOEXCEPT;
bool handle_get_block_template(const code& ec,
rpc_interface::get_block_template) NOEXCEPT;
rpc_interface::get_block_template,
const network::rpc::object_t& template_request) NOEXCEPT;
bool handle_get_prioritised_transactions(const code& ec,
rpc_interface::get_prioritised_transactions) NOEXCEPT;
bool handle_prioritise_transaction(const code& ec,
Expand All @@ -75,6 +76,12 @@ class BCS_API protocol_bitcoind_mining
/// Organize completions (bounced to the channel strand).
void handle_organize_header(const code& ec, size_t height) NOEXCEPT;
void do_submit_header(const code& ec) NOEXCEPT;

/// Template completions (bounced to the channel strand).
void handle_template(const code& ec, size_t height,
const database::tx_links& links) NOEXCEPT;
void do_template(const code& ec, size_t height,
const database::tx_links& links) NOEXCEPT;
};

} // namespace server
Expand Down
26 changes: 15 additions & 11 deletions include/bitcoin/server/protocols/protocol_native.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,35 @@ class BCS_API protocol_native

bool handle_get_block(const code& ec, interface::block,
uint8_t version, uint8_t media, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height, bool witness) NOEXCEPT;
std::optional<uint32_t> height, bool witness, bool candidate) NOEXCEPT;
bool handle_get_block_header(const code& ec, interface::block_header,
uint8_t version, uint8_t media, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_header_context(const code& ec, interface::block_header_context,
uint8_t version, uint8_t media, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_details(const code& ec, interface::block_details,
uint8_t version, uint8_t media, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_txs(const code& ec, interface::block_txs,
uint8_t version, uint8_t media, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_filter(const code& ec, interface::block_filter,
uint8_t version, uint8_t media, uint8_t type,
std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_filter_hash(const code& ec,
interface::block_filter_hash, uint8_t version, uint8_t media,
uint8_t type, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_filter_header(const code& ec,
interface::block_filter_header, uint8_t version, uint8_t media,
uint8_t type, std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height) NOEXCEPT;
std::optional<uint32_t> height, bool candidate) NOEXCEPT;
bool handle_get_block_tx(const code& ec, interface::block_tx,
uint8_t version, uint8_t media, uint32_t position,
std::optional<system::hash_cptr> hash,
std::optional<uint32_t> height, bool witness) NOEXCEPT;
std::optional<uint32_t> height, bool witness, bool candidate) NOEXCEPT;
bool handle_get_block_subscribe(const code& ec, interface::block_subscribe,
uint8_t version, uint8_t media, bool stop) NOEXCEPT;

Expand Down Expand Up @@ -189,7 +189,7 @@ class BCS_API protocol_native

/// Notification event handlers.
/// -----------------------------------------------------------------------
void do_top(node::header_t link, media_type media) NOEXCEPT;
void do_top(media_type media) NOEXCEPT;
void do_block(node::header_t link, media_type media) NOEXCEPT;
void do_transaction(node::transaction_t link, media_type media) NOEXCEPT;

Expand Down Expand Up @@ -260,8 +260,12 @@ class BCS_API protocol_native
void inject(system::json::value& out, std::optional<uint32_t> height,
const database::header_link& link) const NOEXCEPT;

system::chain::checkpoint get_top(bool candidate) const NOEXCEPT;
system::data_chunk to_tops() const NOEXCEPT;
system::json::value to_tops_json() const NOEXCEPT;
database::header_link to_header(const std::optional<uint32_t>& height,
const std::optional<system::hash_cptr>& hash) NOEXCEPT;
const std::optional<system::hash_cptr>& hash,
bool candidate = false) NOEXCEPT;

// These are thread safe, strand uses network threadpool.
network::io::strand notification_strand_;
Expand Down
9 changes: 9 additions & 0 deletions src/parsers/native_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ bool native_query(rpc::request_t& out, const std::string& target,
return false;
}

// Candidate is optional<false> (where applicable), so only set if true.
if (const auto candidate = query.find(token::candidate); candidate != query.cend())
{
if (is_true(candidate->second))
params[token::candidate] = true;
else if (!is_false(candidate->second))
return false;
}

// Stop is optional<false> (where applicable), so only set if true.
if (const auto stop = query.find(token::stop); stop != query.cend())
{
Expand Down
Loading
Loading