From d3e2057ec9d47aa94dda138b4e2a964b4248da5c Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 27 Mar 2014 12:57:56 -0600 Subject: [PATCH] Daemons will rarely arbitrarily drop blocks that it previously considered valid. This is a bug in the daemon or maybe only in testnet. This fix treats those dropped blocks as orhpans. --- libs/paymentProcessor.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 7d6a83e..ead7e79 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -137,13 +137,24 @@ function SetupForPool(logger, poolOptions){ return; } - txDetails = txDetails.filter(function(tx){ - if (tx.error || !tx.result){ + txDetails.forEach(function(tx, i){ + if (tx.error && tx.error.code === -5){ + /* Block was dropped from coin daemon even after it happily accepted it earlier. + Must be a bug in the daemon code or maybe only something that happens in testnet. + We handle this by treating it like an orphaned block. */ + logger.error(logSystem, logComponent, + 'Daemon dropped a previously valid block - we are treating it as an orphaned block'); + + //These changes to the tx will convert it from dropped to orphan + tx.result = { + txid: rounds[i].txHash, + details: [{category: 'orphan'}] + }; + } + else if (tx.error || !tx.result){ logger.error(logSystem, logComponent, 'error with requesting transaction from block daemon: ' + JSON.stringify(tx)); - return false; } - return true; });