-
Notifications
You must be signed in to change notification settings - Fork 296
Conversation
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
@@ -142,6 +142,11 @@ namespace iroha { | |||
if (boost::size(transaction->signatures()) < transaction->quorum()) { | |||
log_->info("waiting for quorum signatures"); | |||
mst_processor_->propagateTransaction(transaction); | |||
status_bus_->publish( |
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 the code to separate function?
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.
This status publishing is done in such way throughout this file, and I think it will be unnecessary hard to move it into a separate function, because we need to put the status somehow, and it's done through the builder. In case of separate function we can pass the builder, but why?
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.
So, after a little discuss, I decided that this task actually is about creating something like status factory, which should be done outside this PR
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.
Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR
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.
Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR
* signatories | ||
*/ | ||
class MstPendingResponse : public AbstractTxResponse<MstPendingResponse> { | ||
private: |
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.
I don't see any reason to do it in private. Maybe change it with the public instead?
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.
This method is private in all similar files for other responses. Should I thus touch them as well with that change?
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.
Well, in this case, add a task for refactoring this with the lowest priority.
shared_model::builder::DefaultTransactionStatusBuilder() | ||
.mstPending() | ||
.txHash(transaction->hash()) | ||
.build()); | ||
return; | ||
} |
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.
Also, there is absent a code for setting status in another one, for example, stateless valid or maybe introduce a new one like prepared to consensus.
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
* - 0, if it's equal | ||
* - 1, if it's greater | ||
*/ | ||
int comparePriorities(const TransactionResponse &other) const noexcept { |
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.
Use enum class
instead
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 do you mean?
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.
enum class Result { LE, EQ, GT, };
Result comparePriorities(const T&) ...
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.
OK, I implemented this method looking at old C functions, strcmp etc, where it's done in this way :) will change it
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 relay operator<, >, == to transactionResponse from priority directly?
.getTransport(); | ||
}()))); | ||
ResponsePtrType initial_status = cache_->findItem(hash).value_or([&] { | ||
log_->debug("tx not received: {}", hash.toString()); |
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.
tx is not ...
* @return priority this transaction response | ||
*/ | ||
int priority() const noexcept { | ||
return iroha::visit_in_place( |
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.
return variant_->which()
?
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.
No, this won't work, because then we should place classes in variant according to their priorities, and this is not as obvious as this visit_in_place
function IMHO
ASSERT_NO_THROW(boost::apply_visitor( | ||
SpecifiedVisitor<interface::MstPendingResponse>(), resp.get())); | ||
}; | ||
// auto checkMstPassedTxStatus = |
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 delete commented lines?
@@ -142,6 +142,11 @@ namespace iroha { | |||
if (boost::size(transaction->signatures()) < transaction->quorum()) { | |||
log_->info("waiting for quorum signatures"); | |||
mst_processor_->propagateTransaction(transaction); | |||
status_bus_->publish( |
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.
Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR
@@ -142,6 +142,11 @@ namespace iroha { | |||
if (boost::size(transaction->signatures()) < transaction->quorum()) { | |||
log_->info("waiting for quorum signatures"); | |||
mst_processor_->propagateTransaction(transaction); | |||
status_bus_->publish( |
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.
Offline discussion:
Move status_bus::publish to the separate method and add a task for refactoring this method in a separate PR
* signatories | ||
*/ | ||
class MstPendingResponse : public AbstractTxResponse<MstPendingResponse> { | ||
private: |
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.
Well, in this case, add a task for refactoring this with the lowest priority.
ASSERT_NO_THROW(boost::apply_visitor( | ||
SpecifiedVisitor<interface::MstPendingResponse>(), resp.get())); | ||
}; | ||
// auto checkEnoughSignaturesCollectedStatus = |
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.
Did you forget to delete that?
@@ -85,6 +109,23 @@ namespace shared_model { | |||
// stub hash | |||
const Lazy<crypto::Hash> hash_{ | |||
[this] { return crypto::Hash(this->proto_->tx_hash()); }}; | |||
|
|||
/** | |||
* @return priority this transaction 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.
Maybe explain what priority means?
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
.build() | ||
.getTransport(); | ||
}()))); | ||
ResponsePtrType initial_status = cache_->findItem(hash).value_or([&] { |
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.
Better to use auto
instead of type.
* - 0, if it's equal | ||
* - 1, if it's greater | ||
*/ | ||
int comparePriorities(const TransactionResponse &other) const noexcept { |
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 relay operator<, >, == to transactionResponse from priority directly?
* @return priority of this transaction response; transaction response can | ||
* only be replaced with one with higher priority | ||
*/ | ||
int priority() const noexcept { |
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.
Seems, this table should be in the interface, not it proto backend.
[](const StatelessFailedTxResponse &) { return 6; }, | ||
[](const StatefulFailedTxResponse &) { return 7; }, | ||
[](const MstExpiredResponse &) { return 8; }, | ||
[](const NotReceivedTxResponse &) { return 9; }); |
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.
Currently, statuses are misleading. For example, why MstExpired is greater than committed?
I suggest reworking priorities with final status priority, which means maximal priority and reflects the impossibility of achieving another status for the transaction. Also, take care of intermediate statuses.
If there will be some troubles, we may arrange an offline meeting.
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
@@ -57,11 +57,10 @@ namespace torii { | |||
auto tx_hash = proto_response->transactionHash(); | |||
auto cached_tx_state = cache_->findItem(tx_hash); | |||
if (cached_tx_state | |||
and proto_response->getTransport().tx_status() | |||
<= cached_tx_state->tx_status()) { | |||
and proto_response->comparePriorities(**cached_tx_state) <= 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.
What is 0
means? Use status constants instead.
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.
It was a value, which compare function gave, so that <= 0
meant that first value is less or equal, than the second one, C-style. But as it's going to be replaced by enum class, doesn't matter
|
||
mst_processor_->onPreparedBatches().subscribe([this](auto &&batch) { | ||
log_->info("MST batch prepared"); | ||
// TODO: 07/08/2018 @muratovv rework interface of pcs::propagate batch | ||
// and mst::propagate batch IR-1584 | ||
for (const auto &tx : batch->transactions()) { |
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.
Seems, code here and at line 128
is duplicated. Maybe refactor it with one method instead?
[](const StatefulValidTxResponse &) { return 4; }, | ||
// following types are the final ones | ||
[](const CommittedTxResponse &) { return max_priority; }, | ||
[](const StatelessFailedTxResponse &) { return max_priority; }, |
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.
Statuses
- StatelessFailedTxResponse
- StatefulFailedTxResponse
- MstExpiredResponse
Are not final.
By your request, I can provide situations where it happens.
* - 0, if it's equal | ||
* - 1, if it's greater | ||
*/ | ||
int comparePriorities(const ModelType &other) const noexcept { |
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.
Use enum class for return type instead.
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
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.
Please check new comments and fix or decline them
Signed-off-by: Akvinikym <[email protected]>
Signed-off-by: Akvinikym <[email protected]>
Description of the Change
This PR adds a MST_PENDING status for transactions, which were sent for further processing into MST processor.
Benefits
Now users will be able to understand, if their transaction is being processed by MST.
Possible Drawbacks
None.