From aa9f3c53c4896bfaecc0d52f9d44c6d921ffab72 Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Fri, 16 Feb 2018 21:46:18 +0100 Subject: [PATCH] [fix] #1277 4th attempt --- app/lib/indexer.ts | 12 +++++++----- app/lib/rules/local_rules.ts | 17 +++++++++-------- app/modules/prover/lib/blockGenerator.ts | 9 +++++---- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/lib/indexer.ts b/app/lib/indexer.ts index b5f1c47be..1985ef4f5 100644 --- a/app/lib/indexer.ts +++ b/app/lib/indexer.ts @@ -1981,11 +1981,13 @@ function txSourceUnlock(ENTRY:SindexEntry, source:SindexEntry, HEAD: DBHead) { const unlockParams:string[] = TransactionDTO.unlock2params(ENTRY.unlock || '') const unlocksMetadata:UnlockMetadata = {} const sigResult = TransactionDTO.fromJSONObject(tx).getTransactionSigResult() - if (source.conditions.match(/CLTV/)) { - unlocksMetadata.currentTime = HEAD.medianTime; - } - if (source.conditions.match(/CSV/)) { - unlocksMetadata.elapsedTime = HEAD.medianTime - source.written_time; + if(source.conditions) { + if (source.conditions.match(/CLTV/)) { + unlocksMetadata.currentTime = HEAD.medianTime; + } + if (source.conditions.match(/CSV/)) { + unlocksMetadata.elapsedTime = HEAD.medianTime - source.written_time; + } } return txunlock(source.conditions, unlockParams, sigResult, unlocksMetadata) } diff --git a/app/lib/rules/local_rules.ts b/app/lib/rules/local_rules.ts index d2f62c6c8..ba102d70d 100644 --- a/app/lib/rules/local_rules.ts +++ b/app/lib/rules/local_rules.ts @@ -391,7 +391,8 @@ export const LOCAL_RULES_FUNCTIONS = { // const allowedMax = block.medianTime > 1519862400 ? CommonConstants.BLOCK_MAX_TX_CHAINING_DEPTH : 0 if (max > allowedMax) { - throw "The maximum transaction chaining length per block is " + CommonConstants.BLOCK_MAX_TX_CHAINING_DEPTH + return false + //throw "The maximum transaction chaining length per block is " + CommonConstants.BLOCK_MAX_TX_CHAINING_DEPTH } return true } @@ -434,17 +435,17 @@ function checkSingleMembershipSignature(ms:any) { return verify(ms.getRaw(), ms.signature, ms.issuer); } -function checkBunchOfTransactions(transactions:TransactionDTO[], conf:ConfDTO, options?:{ dontCareAboutChaining?:boolean }):Promise<boolean>{ +async function checkBunchOfTransactions(transactions:TransactionDTO[], conf:ConfDTO, options?:{ dontCareAboutChaining?:boolean }):Promise<boolean>{ const block:any = { transactions, identities: [], joiners: [], actives: [], leavers: [], revoked: [], excluded: [], certifications: [] }; const index = Indexer.localIndex(block, conf) let local_rule = LOCAL_RULES_FUNCTIONS; return Promise.all([ - local_rule.checkTxLen(block), - local_rule.checkTxIssuers(block), - local_rule.checkTxSources(block), - local_rule.checkTxRecipients(block), - local_rule.checkTxAmounts(block), - local_rule.checkTxSignature(block), + await local_rule.checkTxLen(block), + await local_rule.checkTxIssuers(block), + await local_rule.checkTxSources(block), + await local_rule.checkTxRecipients(block), + await local_rule.checkTxAmounts(block), + await local_rule.checkTxSignature(block), local_rule.checkMaxTransactionChainingDepth(block, conf, index), ]).then(function(values) { for (const value of values) { diff --git a/app/modules/prover/lib/blockGenerator.ts b/app/modules/prover/lib/blockGenerator.ts index 5ed9d9b41..16edbba7a 100644 --- a/app/modules/prover/lib/blockGenerator.ts +++ b/app/modules/prover/lib/blockGenerator.ts @@ -120,10 +120,11 @@ export class BlockGenerator { await GLOBAL_RULES_HELPERS.checkSingleTransaction(tx, nextBlockWithFakeTimeVariation, this.conf, this.dal, ALSO_CHECK_PENDING_TXS), await GLOBAL_RULES_HELPERS.checkTxBlockStamp(tx, this.dal) ]).then(function(values) { - if (values[0] && values[1]) - transactions.push(tx); - passingTxs.push(tx); - logger.info('Transaction %s added to block', tx.hash); + if (values[0] && values[1]) { + transactions.push(tx); + passingTxs.push(tx); + logger.info('Transaction %s added to block', tx.hash); + } }).catch (function(err) { logger.error(err); const currentNumber = (current && current.number) || 0; -- GitLab