generated from Warchant/cmake-hunter-seed
-
Notifications
You must be signed in to change notification settings - Fork 36
Fixes for miner #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Fixes for miner #599
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
namespace fc::common { | ||
|
||
/** | ||
* Class to put move-only lambdas in std::function interface | ||
*/ | ||
template <typename T> | ||
class PutInFunction { | ||
public: | ||
explicit PutInFunction(T &&function) | ||
: move_function_{std::make_shared<T>(std::move(function))} {}; | ||
|
||
template <typename... Args> | ||
auto operator()(Args &&...args) const { | ||
return move_function_->operator()(std::forward<Args>(args)...); | ||
} | ||
|
||
private: | ||
std::shared_ptr<T> move_function_; | ||
}; | ||
} // namespace fc::common |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <gsl/span> | ||
#include <variant> | ||
|
||
namespace fc { | ||
|
||
template <typename T> | ||
class VectorCoW { | ||
public: | ||
using VectorType = std::vector<T>; | ||
using SpanType = gsl::span<const T>; | ||
|
||
VectorCoW() = default; | ||
// NOLINTNEXTLINE(google-explicit-constructor) | ||
VectorCoW(VectorType &&vector) : variant_{std::move(vector)} {} | ||
VectorCoW(const VectorType &vector) = delete; | ||
// NOLINTNEXTLINE(google-explicit-constructor) | ||
VectorCoW(const SpanType &span) : variant_{span} {} | ||
VectorCoW(const VectorCoW<T> &) = delete; | ||
VectorCoW(VectorCoW<T> &&) = default; | ||
VectorCoW<T> &operator=(const VectorCoW<T> &) = delete; | ||
VectorCoW<T> &operator=(VectorCoW<T> &&) = default; | ||
~VectorCoW() = default; | ||
|
||
bool owned() const { | ||
return variant_.index() == 1; | ||
} | ||
|
||
SpanType span() const { | ||
if (!owned()) { | ||
return std::get<SpanType>(variant_); | ||
} | ||
return SpanType{std::get<VectorType>(variant_)}; | ||
} | ||
|
||
size_t size() const { | ||
return span().size(); | ||
} | ||
|
||
bool empty() const { | ||
return span().empty(); | ||
} | ||
|
||
// get mutable container reference, copy once if span | ||
VectorType &mut() { | ||
if (!owned()) { | ||
const auto span = std::get<SpanType>(variant_); | ||
variant_.template emplace<VectorType>(span.begin(), span.end()); | ||
} | ||
return std::get<VectorType>(variant_); | ||
} | ||
|
||
// move container away, copy once if span | ||
VectorType into() { | ||
auto vector{std::move(mut())}; | ||
variant_.template emplace<SpanType>(); | ||
return vector; | ||
} | ||
|
||
private: | ||
std::variant<SpanType, VectorType> variant_; | ||
}; | ||
} // namespace fc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -681,10 +681,7 @@ namespace fc::markets::storage::provider { | |
deal_context->deal->is_fast_retrieval}); | ||
FSM_HALT_ON_ERROR( | ||
maybe_piece_location, "Unable to locate piece", deal_context); | ||
FSM_HALT_ON_ERROR( | ||
recordPieceInfo(deal_context->deal, maybe_piece_location.value()), | ||
"Record piece failed", | ||
deal_context); | ||
deal_context->maybe_piece_location = maybe_piece_location.value(); | ||
// TODO(a.chernyshov): add piece retry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose the comment is not relevant anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be relevant, if sealing cannot store it for now. But after sometime it could |
||
FSM_SEND(deal_context, ProviderEvent::ProviderEventDealHandedOff); | ||
} | ||
|
@@ -700,6 +697,17 @@ namespace fc::markets::storage::provider { | |
} | ||
|
||
FSM_HANDLE_DEFINITION(StorageProviderImpl::onProviderEventDealActivated) { | ||
if (not deal_context->maybe_piece_location.has_value()) { | ||
(deal_context)->deal->message = "Unknown piece location"; | ||
FSM_SEND((deal_context), ProviderEvent::ProviderEventFailed); | ||
return; | ||
} | ||
|
||
FSM_HALT_ON_ERROR( | ||
recordPieceInfo(deal_context->deal, | ||
deal_context->maybe_piece_location.value()), | ||
"Record piece failed", | ||
deal_context); | ||
// TODO(a.chernyshov): wait expiration | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.