mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Input responses while syncing. (#323)
* Send pending input responses after syncing. * Send input statuses on expired inputs. * Sqlite no journal.
This commit is contained in:
@@ -11,7 +11,9 @@ namespace status
|
||||
util::sequence_hash lcl_id; // Last ledger id/hash pair.
|
||||
ledger::ledger_record last_ledger; // Last ledger record that the node created.
|
||||
|
||||
std::atomic<bool> in_sync = false; // Indicates whether this node is in sync with other nodes or not.
|
||||
// Indicates whether this node is in sync with other nodes or not.
|
||||
// -1=unknown, 0=not-in-sync, 1=in-sync
|
||||
std::atomic<int> in_sync = -1;
|
||||
|
||||
std::shared_mutex unl_mutex;
|
||||
std::set<std::string> unl; // List of last reported unl binary pubkeys.
|
||||
@@ -26,13 +28,14 @@ namespace status
|
||||
// Not acquiring the mutex lock since this is called during startup only.
|
||||
lcl_id = ledger_id;
|
||||
last_ledger = ledger;
|
||||
|
||||
// We assume we are not in sync unless otherwise found that we are.
|
||||
in_sync = false;
|
||||
}
|
||||
|
||||
void ledger_created(const util::sequence_hash &ledger_id, const ledger::ledger_record &ledger)
|
||||
{
|
||||
// If currently not-in-sync, report it as in-sync when a ledger is created.
|
||||
if (in_sync != 1)
|
||||
sync_status_changed(true);
|
||||
|
||||
std::unique_lock lock(ledger_mutex);
|
||||
lcl_id = ledger_id;
|
||||
last_ledger = ledger;
|
||||
@@ -41,11 +44,8 @@ namespace status
|
||||
|
||||
void sync_status_changed(const bool new_in_sync)
|
||||
{
|
||||
if (in_sync != new_in_sync)
|
||||
{
|
||||
in_sync = new_in_sync;
|
||||
event_queue.try_enqueue(sync_status_change_event{new_in_sync});
|
||||
}
|
||||
in_sync = new_in_sync ? 1 : 0;
|
||||
event_queue.try_enqueue(sync_status_change_event{new_in_sync});
|
||||
}
|
||||
|
||||
const util::sequence_hash get_lcl_id()
|
||||
@@ -56,7 +56,13 @@ namespace status
|
||||
|
||||
const bool is_in_sync()
|
||||
{
|
||||
return in_sync;
|
||||
return in_sync == 1;
|
||||
}
|
||||
|
||||
const ledger::ledger_record get_last_ledger()
|
||||
{
|
||||
std::shared_lock lock(ledger_mutex);
|
||||
return last_ledger;
|
||||
}
|
||||
|
||||
//----- UNL status
|
||||
|
||||
Reference in New Issue
Block a user