Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update full node to 2.14.9 #64

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading