Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,7 @@ export class DelegateResignationTransactionHandler extends TransactionHandler {
pool: TransactionPool.IConnection,
processor: TransactionPool.IProcessor,
): Promise<boolean> {
if (await this.typeFromSenderAlreadyInPool(data, pool, processor)) {
const wallet: State.IWallet = pool.walletManager.findByPublicKey(data.senderPublicKey);
processor.pushError(
data,
"ERR_PENDING",
`Delegate resignation for "${wallet.getAttribute("delegate.username")}" already in the pool`,
);
return false;
}

return true;
return !await this.typeFromSenderAlreadyInPool(data, pool, processor);
}

public async applyToSender(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ export class MultiSignatureTransactionHandler extends TransactionHandler {
pool: TransactionPool.IConnection,
processor: TransactionPool.IProcessor,
): Promise<boolean> {
if (await this.typeFromSenderAlreadyInPool(data, pool, processor)) {
return false;
}

return true;
return !await this.typeFromSenderAlreadyInPool(data, pool, processor);
}

public async applyToSender(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ export class SecondSignatureTransactionHandler extends TransactionHandler {
pool: TransactionPool.IConnection,
processor: TransactionPool.IProcessor,
): Promise<boolean> {
if (await this.typeFromSenderAlreadyInPool(data, pool, processor)) {
return false;
}

return true;
return !await this.typeFromSenderAlreadyInPool(data, pool, processor);
}

public async applyToSender(
Expand Down
6 changes: 1 addition & 5 deletions packages/core-transactions/src/handlers/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ export class VoteTransactionHandler extends TransactionHandler {
pool: TransactionPool.IConnection,
processor: TransactionPool.IProcessor,
): Promise<boolean> {
if (await this.typeFromSenderAlreadyInPool(data, pool, processor)) {
return false;
}

return true;
return !await this.typeFromSenderAlreadyInPool(data, pool, processor);
}

public async applyToSender(
Expand Down
6 changes: 6 additions & 0 deletions packages/core-transactions/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export interface ITransactionHandler {
apply(transaction: Interfaces.ITransaction, walletManager: State.IWalletManager): Promise<void>;
revert(transaction: Interfaces.ITransaction, walletManager: State.IWalletManager): Promise<void>;

/**
* Check if a transaction of this type can enter the pool.
* If `false` is returned to designate that the transaction cannot enter the pool,
* then this method will have called processor.pushError() to give a detailed
* description of the reason.
*/
canEnterTransactionPool(
data: Interfaces.ITransactionData,
pool: TransactionPool.IConnection,
Expand Down