Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

API.storeAndBroadcast calls runValidation multiple times for same set of tx #225

@dnck

Description

@dnck

Expected behavior

Is this expected behavior?

Milestone publishing calls the TransactionValidator.runValidation method at least three times on the same set of transactions...

This seems to be accidental.


Trace details

The API.storeAndBroadcast method

private void storeAndBroadcast(Hash tip1, Hash tip2, int mwm, List<String> txs) throws Exception{
calls the API.attachToTangleStatement method
public synchronized List<String> attachToTangleStatement(final Hash trunkTransaction, final Hash branchTransaction, int minWeightMagnitude, final List<String> txs) {
which leads to a call of TransactionValidator.runValidation method
runValidation(transactionViewModel, minWeightMagnitude);
through the tx validator's validateBytes method.
final TransactionViewModel transactionViewModel = transactionValidator.validateBytes(txBytes, transactionValidator.getMinWeightMagnitude());
(END FIRST CALL)

After finishing with the above, the API.storeAndBroadcast method calls the API. storeTransactionsStatement method,

storeTransactionsStatement(powResult);
which results in the API.addValidTxvmToList method,
final List<TransactionViewModel> elements = addValidTxvmToList(txString);
calling TransactionValidator.runValidation method for the second time.
final TransactionViewModel transactionViewModel = transactionValidator.validateBytes(
txBytes, transactionValidator.getMinWeightMagnitude()
);
(END SECOND CALL)

Finally, the broadcastTransactionsStatement at the end of the API.storeAndBroadcast method

broadcastTransactionsStatement(powResult);
calls again the API.addValidTxvmToList method
final List<TransactionViewModel> elements = addValidTxvmToList(txString);
which results in a final call to TransactionValidator.runValidation for presumably the same set of tx that had already undergone validation twice before. (END THIRD CALL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions