Skip to content
Snippets Groups Projects
Commit 30a92453 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #849 GTest currency has buggy protocol implementation

parent 87636ebf
Branches
Tags
No related merge requests found
......@@ -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);
......
......@@ -1444,9 +1444,13 @@ const indexer = module.exports = {
let basedBlock = { medianTime: 0 };
if (HEAD.number == 0) {
basedBlock = HEAD;
} else {
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;
}
......@@ -1459,9 +1463,13 @@ const indexer = module.exports = {
let basedBlock = { medianTime: 0 };
if (HEAD.number == 0) {
basedBlock = HEAD;
} else {
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;
}
}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment