From 8059dc5487cd60a2e763096ca59280e448896551 Mon Sep 17 00:00:00 2001 From: Manu Nelamane Siddalingegowda Date: Tue, 5 May 2020 12:00:07 +0200 Subject: [PATCH] :recycle: Fix minor type issues --- elements/lisk-transaction-pool/src/types.ts | 2 +- .../src/application/node/forger/forger.ts | 3 ++- .../src/application/node/forger/strategies.ts | 23 ++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/elements/lisk-transaction-pool/src/types.ts b/elements/lisk-transaction-pool/src/types.ts index baa7f2fd277..167e236c3b9 100644 --- a/elements/lisk-transaction-pool/src/types.ts +++ b/elements/lisk-transaction-pool/src/types.ts @@ -26,7 +26,7 @@ export interface TransactionObject { signatures?: ReadonlyArray; readonly type: number; verifiedOnce?: boolean; - feePriority: bigint; + feePriority?: bigint; } export interface TransactionFunctions { diff --git a/framework/src/application/node/forger/forger.ts b/framework/src/application/node/forger/forger.ts index b2030ecb065..c6f60118975 100644 --- a/framework/src/application/node/forger/forger.ts +++ b/framework/src/application/node/forger/forger.ts @@ -207,7 +207,8 @@ export class Forger { keypair.publicKey.toString('hex'), ]); - if (account.isDelegate) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (account?.isDelegate) { if (forging) { this.keypairs[ getAddressFromPublicKey(keypair.publicKey.toString('hex')) diff --git a/framework/src/application/node/forger/strategies.ts b/framework/src/application/node/forger/strategies.ts index 47dcfc9d012..219e07d9229 100644 --- a/framework/src/application/node/forger/strategies.ts +++ b/framework/src/application/node/forger/strategies.ts @@ -13,14 +13,17 @@ */ import { MaxHeap, TransactionPool } from '@liskhq/lisk-transaction-pool'; -import { Status as TransactionStatus, BaseTransaction } from '@liskhq/lisk-transactions'; +import { + Status as TransactionStatus, + BaseTransaction, +} from '@liskhq/lisk-transactions'; import { Chain } from '@liskhq/lisk-chain'; export class HighFeeForgingStrategy { private readonly chainModule: Chain; private readonly transactionPoolModule: TransactionPool; private readonly constants: { - readonly maxPayloadLength: number + readonly maxPayloadLength: number; }; public constructor({ @@ -30,9 +33,9 @@ export class HighFeeForgingStrategy { // constants maxPayloadLength, }: { - readonly chainModule: Chain, - readonly transactionPoolModule: TransactionPool, - readonly maxPayloadLength: number + readonly chainModule: Chain; + readonly transactionPoolModule: TransactionPool; + readonly maxPayloadLength: number; }) { this.chainModule = chainModule; this.transactionPoolModule = transactionPoolModule; @@ -55,13 +58,17 @@ export class HighFeeForgingStrategy { const feePriorityHeap = new MaxHeap(); for (const senderId of Object.keys(transactionsBySender)) { const lowestNonceTrx = transactionsBySender[senderId][0]; - feePriorityHeap.push(lowestNonceTrx.feePriority, lowestNonceTrx); + feePriorityHeap.push( + lowestNonceTrx.feePriority as bigint, + lowestNonceTrx, + ); } // Loop till we have last account exhausted to pick transactions while (Object.keys(transactionsBySender).length !== 0) { // Get the transaction with highest fee and lowest nonce - const lowestNonceHighestFeeTrx = (feePriorityHeap.pop()?.value) as BaseTransaction; + const lowestNonceHighestFeeTrx = feePriorityHeap.pop() + ?.value as BaseTransaction; // Try to process transaction const result = await this.chainModule.applyTransactionsWithStateStore( [lowestNonceHighestFeeTrx], @@ -115,7 +122,7 @@ export class HighFeeForgingStrategy { const nextLowestNonceTransaction = transactionsBySender[lowestNonceHighestFeeTrx.senderId][0]; feePriorityHeap.push( - nextLowestNonceTransaction.feePriority, + nextLowestNonceTransaction.feePriority as bigint, nextLowestNonceTransaction, ); }