diff --git a/app/lib/dal/fileDAL.js b/app/lib/dal/fileDAL.js index d0993aae0a6cdbf280cdfa3a168ce0e7b2feee1a..1da9a15636f65428cc7e57dc6695125683f5861a 100644 --- a/app/lib/dal/fileDAL.js +++ b/app/lib/dal/fileDAL.js @@ -103,6 +103,11 @@ function FileDAL(params) { return block || null; }); + this.getBlockBuggy = (number) => co(function*() { + const block = yield that.blockDAL.getBlock(Math.max(0, number - 1)); // This is the bug: we look at previous block + return block || null; + }); + this.getAbsoluteBlockByNumberAndHash = (number, hash) => that.blockDAL.getAbsoluteBlock(number, hash); @@ -122,6 +127,10 @@ function FileDAL(params) { return that.getBlockByNumberAndHash(number, hash); }; + this.getBlockByBlockstampBuggy = (blockstamp) => { + return that.getBlockBuggy(parseInt(blockstamp)); + }; + this.getBlockByNumberAndHash = (number, hash) => co(function*() { try { const block = yield that.getBlock(number); diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js index d5719d4f1eeccce4bebef85696e1e66550900ab2..519c3bd84584b0dc806c5cb43b64d2ec699d418f 100644 --- a/app/lib/dup/indexer.js +++ b/app/lib/dup/indexer.js @@ -1445,7 +1445,11 @@ const indexer = module.exports = { if (HEAD.number == 0) { basedBlock = HEAD; } else { - basedBlock = yield dal.getBlockByBlockstamp(MS.created_on); + if (HEAD.currency === 'gtest') { + basedBlock = yield dal.getBlockByBlockstampBuggy(MS.created_on); // TODO: fix for v1.0.0 + } else { + basedBlock = yield dal.getBlockByBlockstamp(MS.created_on); + } } MS.expires_on += basedBlock.medianTime; MS.revokes_on += basedBlock.medianTime; @@ -1460,7 +1464,11 @@ const indexer = module.exports = { if (HEAD.number == 0) { basedBlock = HEAD; } else { - basedBlock = yield dal.getBlock(CERT.created_on); + if (HEAD.currency === 'gtest') { + basedBlock = yield dal.getBlockBuggy(CERT.created_on); // TODO: fix for v1.0.0 + } else { + basedBlock = yield dal.getBlock(CERT.created_on); + } } CERT.expires_on += basedBlock.medianTime; } diff --git a/package.json b/package.json index b88fd5504623ada3d29acc9801cde19d7b6ce8d3..e6e51c4708b53db4da60e84635fcfa2cc9f62cdd 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "daemonize2": "0.4.2", "duniter-bma": "^0.2.11", "duniter-common": "0.1.0", - "duniter-crawler": "^0.2.9", + "duniter-crawler": "^0.2.10", "duniter-keypair": "^0.3.0", "duniter-prover": "^0.2.6", "event-stream": "3.3.4",