Skip to content

Commit

Permalink
GH-1039 add ability to broadcast a block from test_control_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Nov 22, 2024
1 parent 20609f9 commit 6fe2a17
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ namespace eosio {
void register_increment_failed_p2p_connections(std::function<void()>&&);
void register_increment_dropped_trxs(std::function<void()>&&);

// for testing
void broadcast_block(const signed_block_ptr& b, const block_id_type& id);

private:
std::shared_ptr<class net_plugin_impl> my;
};
Expand Down
5 changes: 5 additions & 0 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4459,6 +4459,11 @@ namespace eosio {
my->increment_dropped_trxs = std::move(fun);
}

void net_plugin::broadcast_block(const signed_block_ptr& b, const block_id_type& id) {
fc_dlog(logger, "broadcasting block ${n} ${id}", ("n", b->block_num())("id", id));
my->dispatcher.bcast_block(b, id);
}

//----------------------------------------------------------------------------

size_t connections_manager::number_connections() const {
Expand Down
2 changes: 1 addition & 1 deletion plugins/test_control_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ add_library( test_control_plugin
test_control_plugin.cpp
${HEADERS} )

target_link_libraries( test_control_plugin producer_plugin chain_plugin http_client_plugin appbase eosio_chain )
target_link_libraries( test_control_plugin producer_plugin chain_plugin net_plugin http_client_plugin appbase eosio_chain )
target_include_directories( test_control_plugin
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <eosio/chain/application.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <eosio/net_plugin/net_plugin.hpp>
#include <fc/variant.hpp>
#include <memory>

Expand Down Expand Up @@ -53,7 +54,7 @@ class read_write {

class test_control_plugin : public plugin<test_control_plugin> {
public:
APPBASE_PLUGIN_REQUIRES((chain_plugin))
APPBASE_PLUGIN_REQUIRES((chain_plugin)(net_plugin))

test_control_plugin();
test_control_plugin(const test_control_plugin&) = delete;
Expand Down

0 comments on commit 6fe2a17

Please sign in to comment.