aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/hotstuff/hotstuff.h12
-rw-r--r--src/hotstuff_app.cpp15
2 files changed, 19 insertions, 8 deletions
diff --git a/include/hotstuff/hotstuff.h b/include/hotstuff/hotstuff.h
index 91001dc..c4b87cf 100644
--- a/include/hotstuff/hotstuff.h
+++ b/include/hotstuff/hotstuff.h
@@ -125,11 +125,13 @@ class BlockDeliveryContext: public promise_t {
class HotStuffBase: public HotStuffCore {
using BlockFetchContext = FetchContext<ENT_TYPE_BLK>;
using CmdFetchContext = FetchContext<ENT_TYPE_CMD>;
- using Net = PeerNetwork<opcode_t>;
friend BlockFetchContext;
friend CmdFetchContext;
+ public:
+ using Net = PeerNetwork<opcode_t>;
+
protected:
/** the binding address in replica network */
NetAddr listen_addr;
@@ -202,7 +204,7 @@ class HotStuffBase: public HotStuffCore {
pacemaker_bt pmaker,
EventContext ec,
size_t nworker,
- const Net::Config &config = Net::Config());
+ const Net::Config &config);
~HotStuffBase();
@@ -266,14 +268,16 @@ class HotStuff: public HotStuffBase {
NetAddr listen_addr,
pacemaker_bt pmaker,
EventContext ec = EventContext(),
- size_t nworker = 4):
+ size_t nworker = 4,
+ const Net::Config &config = Net::Config()):
HotStuffBase(blk_size,
rid,
new PrivKeyType(raw_privkey),
listen_addr,
std::move(pmaker),
ec,
- nworker) {}
+ nworker,
+ config) {}
void add_replica(ReplicaID idx, const NetAddr &addr, const bytearray_t &pubkey_raw) {
DataStream s(pubkey_raw);
diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp
index d14738c..c2da528 100644
--- a/src/hotstuff_app.cpp
+++ b/src/hotstuff_app.cpp
@@ -118,7 +118,8 @@ class HotStuffApp: public HotStuff {
NetAddr clisten_addr,
hotstuff::pacemaker_bt pmaker,
const EventContext &ec,
- size_t nworker);
+ size_t nworker,
+ const Net::Config &config);
void start();
};
@@ -151,6 +152,7 @@ int main(int argc, char **argv) {
auto opt_qc_timeout = Config::OptValDouble::create(0.5);
auto opt_imp_timeout = Config::OptValDouble::create(11);
auto opt_nworker = Config::OptValInt::create(4);
+ auto opt_netnworker = Config::OptValInt::create(4);
config.add_opt("block-size", opt_blk_size, Config::SET_VAL);
config.add_opt("parent-limit", opt_parent_limit, Config::SET_VAL);
@@ -164,6 +166,7 @@ int main(int argc, char **argv) {
config.add_opt("qc-timeout", opt_qc_timeout, Config::SET_VAL, 't', "set QC timeout (for sticky)");
config.add_opt("imp-timeout", opt_imp_timeout, Config::SET_VAL, 'u', "set impeachment timeout (for sticky)");
config.add_opt("nworker", opt_nworker, Config::SET_VAL, 'n', "the number of threads for verification");
+ config.add_opt("netnworker", opt_nworker, Config::SET_VAL, 'm', "the number of threads for network");
config.add_opt("help", opt_help, Config::SWITCH_ON, 'h', "show this help info");
EventContext ec;
@@ -209,6 +212,8 @@ int main(int argc, char **argv) {
else
pmaker = new hotstuff::PaceMakerDummyFixed(opt_fixed_proposer->get(), parent_limit);
+ HotStuffApp::Net::Config netconfig;
+ netconfig.nworker(opt_netnworker->get());
papp = new HotStuffApp(opt_blk_size->get(),
opt_stat_period->get(),
opt_imp_timeout->get(),
@@ -218,7 +223,8 @@ int main(int argc, char **argv) {
NetAddr("0.0.0.0", client_port),
std::move(pmaker),
ec,
- opt_nworker->get());
+ opt_nworker->get(),
+ netconfig);
for (size_t i = 0; i < replicas.size(); i++)
{
auto p = split_ip_port_cport(replicas[i].first);
@@ -245,9 +251,10 @@ HotStuffApp::HotStuffApp(uint32_t blk_size,
NetAddr clisten_addr,
hotstuff::pacemaker_bt pmaker,
const EventContext &ec,
- size_t nworker):
+ size_t nworker,
+ const Net::Config &config):
HotStuff(blk_size, idx, raw_privkey,
- plisten_addr, std::move(pmaker), ec, nworker),
+ plisten_addr, std::move(pmaker), ec, nworker, config),
stat_period(stat_period),
impeach_timeout(impeach_timeout),
ec(ec),