From 811619ba36d0151d451647fe55e7a16d44b56357 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 22 May 2019 02:51:43 -0400 Subject: optimize exec_command --- include/hotstuff/hotstuff.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/hotstuff/hotstuff.h b/include/hotstuff/hotstuff.h index 43ed3a4..313511f 100644 --- a/include/hotstuff/hotstuff.h +++ b/include/hotstuff/hotstuff.h @@ -131,6 +131,7 @@ class HotStuffBase: public HotStuffCore { public: using Net = PeerNetwork; + using commit_cb_t = std::function; protected: /** the binding address in replica network */ @@ -154,8 +155,10 @@ class HotStuffBase: public HotStuffCore { /* queues for async tasks */ std::unordered_map blk_fetch_waiting; std::unordered_map blk_delivery_waiting; - std::unordered_map decision_waiting; - std::queue cmd_pending; + std::unordered_map decision_waiting; + using cmd_queue_t = salticidae::MPSCQueueEventDriven>; + cmd_queue_t cmd_pending; + std::queue cmd_pending_buffer; /* statistics */ uint64_t fetched; @@ -211,7 +214,7 @@ class HotStuffBase: public HotStuffCore { /* the API for HotStuffBase */ /* Submit the command to be decided. */ - promise_t exec_command(uint256_t cmd); + void exec_command(uint256_t cmd_hash, commit_cb_t callback); void start(std::vector> &&replicas, bool ec_loop = false); size_t size() const { return peers.size(); } -- cgit v1.2.3-70-g09d2