From 87d08c5a45602534ceaea7e97bd02a660bc663f1 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Tue, 19 Jun 2018 20:39:04 -0300 Subject: [PATCH] some comments --- src/crosschain.cpp | 25 ++++++++++++++++++++----- src/rpccrosschain.cpp | 3 +-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/crosschain.cpp b/src/crosschain.cpp index 4f19f0eb2..ca7223abb 100644 --- a/src/crosschain.cpp +++ b/src/crosschain.cpp @@ -4,14 +4,29 @@ #include "main.h" #include "notarisationdb.h" +/* + * The crosschain workflow. + * + * 3 chains, A, B, and KMD. We would like to prove TX on B. + * There is a notarisation, nA0, which will include TX via an MoM. + * The notarisation nA0 must fall between 2 notarisations of B, + * ie, nB0 and nB1. An MoMoM including this range is propagated to + * B in notarisation receipt (backnotarisation) bnB2. + * + * A: TX bnA0 + * \ / + * KMD: nB0 nA0 nB1 nB2 + * \ \ \ + * B: bnB0 bnB1 bnB2 + */ + +// XXX: There are potential crashes wherever we access chainActive without a lock, +// because it might be disconnecting blocks at the same time. + int NOTARISATION_SCAN_LIMIT_BLOCKS = 1440; -/* - * This file is built in the server - */ - /* On KMD */ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight, std::vector &moms, uint256 &destNotarisationTxid) @@ -258,7 +273,7 @@ TxProof GetAssetchainProof(uint256 hash) return nota.second.height >= blockIndex->nHeight; }; if (!ScanNotarisationsFromHeight(blockIndex->nHeight, isTarget, nota)) - throw std::runtime_error("notarisation not found"); + throw std::runtime_error("backnotarisation not yet confirmed"); // index of block in MoM leaves nIndex = nota.second.height - blockIndex->nHeight; diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index c99581406..35542613a 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -19,11 +19,10 @@ #include "script/standard.h" #include - #include - #include + using namespace std; int32_t komodo_MoM(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);