Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Retry verifybmm after delay if cannot read block
Browse files Browse the repository at this point in the history
* In case the sidechain tries to verify BMM with the mainchain before
  the mainchain has flushed the block to disk retry verifybmm RPC
  request after 5 seconds
  • Loading branch information
CryptAxe committed May 2, 2024
1 parent b32fa70 commit fb882c5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/sidechainclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <univalue.h>
#include <utilmoneystr.h>
#include <utilstrencodings.h>
#include <utiltime.h>
#include <util.h>

#include <iostream>
Expand Down Expand Up @@ -212,11 +213,20 @@ bool SidechainClient::VerifyBMM(const uint256& hashMainBlock, const uint256& has
json.append("] }");

// Try to request BMM proof from mainchain
// TODO this should read the response from mainchain and then sleep
// only if the error message is failed to read block from disk.
boost::property_tree::ptree ptree;
if (!SendRequestToMainchain(json, ptree)) {
// Can be enabled for debug -- too noisy
// LogPrintf("ERROR Sidechain client failed to request BMM proof\n");
return false;
// TODO if the response was failed to read from disk then retry
// Retry after waiting 5 seconds for main node to flush state

MilliSleep(5000);

if (!SendRequestToMainchain(json, ptree)) {
// Can be enabled for debug -- too noisy
// LogPrintf("ERROR Sidechain client failed to request BMM proof\n");
return false;
}
}

// Process result
Expand Down

0 comments on commit fb882c5

Please sign in to comment.