-
Notifications
You must be signed in to change notification settings - Fork 297
Conversation
irohad/torii/command_service.hpp
Outdated
@@ -29,6 +29,7 @@ | |||
#include "endpoint.pb.h" | |||
#include "logger/logger.hpp" | |||
#include "torii/processor/transaction_processor.hpp" | |||
#include "torii/status_bus_impl.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status_bus.hpp?
irohad/torii/command_service.hpp
Outdated
void addTxToCacheAndLog(const std::string &who, | ||
const shared_model::crypto::Hash &hash, | ||
const iroha::protocol::ToriiResponse &response); | ||
void pushStatus(const std::string &who, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment please
} | ||
|
||
void StatusBusImpl::update() { | ||
while (not q_.empty() and q_.try_pop(obj_)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need to check for emptiness, try_pop returns false if the queue is empty.
std::shared_ptr<iroha::torii::StatusBus> status_bus) | ||
: pcs_(std::move(pcs)), | ||
mst_processor_(std::move(mst_processor)), | ||
status_bus_(status_bus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move here?
irohad/torii/status_bus_impl.hpp
Outdated
#include <mutex> | ||
#include <thread> | ||
|
||
#include <tbb/concurrent_queue.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add empty line after include please
@@ -155,7 +150,7 @@ namespace torii { | |||
// Send transaction to iroha | |||
tx_processor_->transactionHandle(tx); | |||
|
|||
this->addTxToCacheAndLog( | |||
this->pushStatus( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and above there is a slight duplication, maybe put it in a function?
status_map[response->transactionHash()] = response; | ||
}); | ||
EXPECT_CALL(*status_bus, publish(_)) | ||
// evey transaction is notified that it is first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
@@ -19,6 +19,7 @@ | |||
|
|||
#include <memory> | |||
|
|||
#include <boost/thread/barrier.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add whitespace please
irohad/main/application.cpp
Outdated
|
||
command_service = std::make_shared<::torii::CommandService>( | ||
tx_processor, storage, std::chrono::seconds(1), 2 * proposal_delay_); | ||
status_bus_ = std::make_shared<StatusBusImpl>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move status bus as a separate method? I think it is will be more clear to a reader of the code. And, also, we will introduce status bus as a dependency in other modules.
@@ -69,6 +64,16 @@ namespace torii { | |||
}); | |||
} | |||
|
|||
namespace { | |||
iroha::protocol::ToriiResponse makeResponse( | |||
shared_model::crypto::Hash h, iroha::protocol::TxStatus status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point to pass parameters as value instead of const ref?
@@ -69,6 +64,16 @@ namespace torii { | |||
}); | |||
} | |||
|
|||
namespace { | |||
iroha::protocol::ToriiResponse makeResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation for the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it self-explanatory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the purpose is hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anonymous namespace make a clue that it's for internal usage
And there's nothing fancy, it just make response with the passed params
namespace { | ||
iroha::protocol::ToriiResponse makeResponse( | ||
shared_model::crypto::Hash h, iroha::protocol::TxStatus status) { | ||
iroha::protocol::ToriiResponse response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using raw proto instead of the model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it used for grpc
@@ -270,7 +264,8 @@ namespace torii { | |||
.build() | |||
.getTransport(); | |||
}()))); | |||
return responses_ | |||
return status_bus_ | |||
->statuses() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code is well-formed with clang-format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
irohad/torii/status_bus.hpp
Outdated
public: | ||
virtual ~StatusBus() = default; | ||
|
||
using Objects = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc for using
irohad/torii/status_bus.hpp
Outdated
/** | ||
* Shares object among the bus users | ||
* @param object to share | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add guarantees of interface about multi-thread interaction. This documentation may be moved to impl class doc.
/** | ||
* @return observable over objects in bus | ||
*/ | ||
virtual rxcpp::observable<Objects> statuses() = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add information about the thread where subscribes will be invoked. This documentation may be moved to impl class doc.
#include "interfaces/transaction_responses/tx_response.hpp" | ||
|
||
namespace iroha { | ||
namespace torii { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the namespace torii? Mabe move it class to libs?
@@ -179,10 +180,29 @@ namespace integration_framework { | |||
std::function<void(const shared_model::proto::TransactionResponse &)> | |||
validation) { | |||
log_->info("send transaction"); | |||
|
|||
boost::barrier bar1(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment with explanation of barriers here.
4750870
to
b2a5906
Compare
- Add StatusBusImpl - Add MockStatusBus - Introduce boost::thread - Use proper synchronization for recieving stateless statuses in ITF::sendTx - Fix cache issue in CommandService - Update dockerfiles - Refactor CommandService with makeResponse Signed-off-by: Kitsu <mail@kitsu.me>
c7772f9
to
9b40cb0
Compare
namespace iroha { | ||
namespace torii { | ||
StatusBusImpl::StatusBusImpl(rxcpp::observe_on_one_worker worker) | ||
: worker_(worker), subject_(worker_) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point to hold worker_
field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it passed directly to the subject_
that will create a new thread for each subscriber
Signed-off-by: Kitsu <mail@kitsu.me>
As |
Description of the Change
Benefits
Cleaner architecture, some work delegate to other unit, lesser RC issues in tests
Possible Drawbacks
None