Skip to content

Commit

Permalink
Update full node to 2.14.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed May 30, 2024
1 parent ace5917 commit 00a833a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/httpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var HttpClient = module.exports = function HttpClient(host, port, apiKey){
}
}
if (res.statusCode !== 200){
dataJson.statusCode = res.statusCode
dataJson.error = dataJson.detail ? dataJson.detail : 'Request error, status code: ' + res.statusCode;
}
return dataJson;
Expand Down
16 changes: 8 additions & 8 deletions lib/shareProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,26 @@ var ShareProcessor = module.exports = function ShareProcessor(config, logger){
}

function getUncleReward(ghostUncleHash, ghostUncleHashWithTs, callback) {
_this.httpClient.getMainChainBlockByGhostUncle(ghostUncleHash, function (block) {
if (block.error) {
var errorMsg = `${block.error}`
if (errorMsg.includes(`Mainchain block by ghost uncle hash ${ghostUncleHash} not found`)) {
_this.httpClient.getMainChainBlockByGhostUncle(ghostUncleHash, function (response) {
if (response.error) {
var errorMsg = `${response.error}`
if (response.statusCode === 404 && errorMsg.includes(`The mainchain block that references the ghost uncle block ${ghostUncleHash} not found`)) {
logger.warn(`Block ${ghostUncleHash} is not a ghost uncle block`);
var [fromGroup, toGroup] = util.blockChainIndex(Buffer.from(ghostUncleHash, 'hex'));
removeBlockAndShares(fromGroup, toGroup, ghostUncleHash, ghostUncleHashWithTs);
} else {
logger.error('Get main chain block error: ' + block.error + ', ghost uncle hash: ' + ghostUncleHash);
logger.error('Get main chain block error: ' + response.error + ', ghost uncle hash: ' + ghostUncleHash);
}
callback(null);
return;
}

var transactions = block.transactions;
var transactions = response.transactions;
var coinbaseTx = transactions[transactions.length - 1];
var index = block.ghostUncles.findIndex((u) => u.blockHash === ghostUncleHash)
var index = response.ghostUncles.findIndex((u) => u.blockHash === ghostUncleHash)
var rewardOutput = coinbaseTx.unsigned.fixedOutputs[index + 1];
var rewardAmount = rewardOutput.attoAlphAmount;
logger.info('Found main chain block ' + block.hash + ', uncle reward: ' + rewardAmount);
logger.info('Found main chain block ' + response.hash + ', uncle reward: ' + rewardAmount);
callback(rewardAmount);
})
}
Expand Down
2 changes: 1 addition & 1 deletion test/shareProcessorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('test share processor', function(){
var redisTx = redisClient.multi();
restServer.persist()
.get('/blockflow/main-chain-block-by-ghost-uncle/' + orphanBlock.hash)
.reply(404, { detail: `Mainchain block by ghost uncle hash ${orphanBlock.hash} not found` });
.reply(404, { detail: `The mainchain block that references the ghost uncle block ${orphanBlock.hash} not found` });
for (var block of blocks){
restServer.persist().get('/blockflow/blocks/' + block.hash).reply(200, block);
var path = '/blockflow/is-block-in-main-chain?blockHash=' + block.hash;
Expand Down

0 comments on commit 00a833a

Please sign in to comment.