Browse Source

Prevent possible skip of notarisation on KMD

pull/4/head
blackjok3r 6 years ago
parent
commit
05908caa14
  1. 14
      src/crosschain.cpp

14
src/crosschain.cpp

@ -69,7 +69,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh
destNotarisationTxid = nota.first;
else if (seenOwnNotarisations == 2)
goto end;
break;
//break;
}
}
@ -97,7 +97,7 @@ int ScanNotarisationsFromHeight(int nHeight, const IsTarget f, Notarisation &fou
{
int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height());
int start = std::max(nHeight, 1);
for (int h=start; h<limit; h++) {
NotarisationsInBlock notarisations;
@ -126,7 +126,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
*/
EvalRef eval;
uint256 MoM = assetChainProof.second.Exec(txid);
// Get a kmd height for given notarisation Txid
int kmdHeight;
{
@ -158,7 +158,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
uint256 MoMoM = CalculateProofRoot(targetSymbol, targetCCid, kmdHeight, moms, targetChainNotarisationTxid);
if (MoMoM.IsNull())
throw std::runtime_error("No MoMs found");
// Find index of source MoM in MoMoM
int nIndex;
for (nIndex=0; nIndex<moms.size(); nIndex++) {
@ -311,7 +311,7 @@ TxProof GetAssetchainProof(uint256 hash)
};
if (!ScanNotarisationsFromHeight(blockIndex->GetHeight(), isTarget, nota))
throw std::runtime_error("backnotarisation not yet confirmed");
// index of block in MoM leaves
nIndex = nota.second.height - blockIndex->GetHeight();
}
@ -325,7 +325,7 @@ TxProof GetAssetchainProof(uint256 hash)
}
bool fMutated;
BuildMerkleTree(&fMutated, leaves, tree);
branch = GetMerkleBranch(nIndex, leaves.size(), tree);
branch = GetMerkleBranch(nIndex, leaves.size(), tree);
// Check branch
uint256 ourResult = SafeCheckMerkleBranch(blockIndex->hashMerkleRoot, branch, nIndex);
@ -364,7 +364,7 @@ TxProof GetAssetchainProof(uint256 hash)
}
// Check the proof
if (nota.second.MoM != CBlock::CheckMerkleBranch(hash, branch, nIndex))
if (nota.second.MoM != CBlock::CheckMerkleBranch(hash, branch, nIndex))
throw std::runtime_error("Failed validating MoM");
// All done!

Loading…
Cancel
Save