-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4824 from pwojcikdev/ledger-notifications-3
Fix out of order ledger notifications
- Loading branch information
Showing
35 changed files
with
497 additions
and
271 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,44 @@ | ||
#pragma once | ||
|
||
#include <nano/node/block_source.hpp> | ||
#include <nano/secure/common.hpp> | ||
|
||
#include <future> | ||
|
||
namespace nano | ||
{ | ||
class block_context | ||
{ | ||
public: | ||
using result_t = nano::block_status; | ||
using callback_t = std::function<void (result_t)>; | ||
|
||
public: // Keep fields public for simplicity | ||
std::shared_ptr<nano::block> block; | ||
nano::block_source source; | ||
callback_t callback; | ||
std::chrono::steady_clock::time_point arrival{ std::chrono::steady_clock::now () }; | ||
|
||
public: | ||
block_context (std::shared_ptr<nano::block> block, nano::block_source source, callback_t callback = nullptr) : | ||
block{ std::move (block) }, | ||
source{ source }, | ||
callback{ std::move (callback) } | ||
{ | ||
debug_assert (source != nano::block_source::unknown); | ||
} | ||
|
||
std::future<result_t> get_future () | ||
{ | ||
return promise.get_future (); | ||
} | ||
|
||
void set_result (result_t result) | ||
{ | ||
promise.set_value (result); | ||
} | ||
|
||
private: | ||
std::promise<result_t> promise; | ||
}; | ||
} |
Oops, something went wrong.