New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i1768 - transactions and wallet api to return Bad Request on invalid tx #1779
i1768 - transactions and wallet api to return Bad Request on invalid tx #1779
Conversation
} | ||
} | ||
|
||
def checkTransactionR: Route = (path("check") & post & entity(as[ErgoTransaction])) { tx => | ||
validateTransactionAndProcess(tx) { tx => tx } | ||
validateTransactionAndProcess(tx) { tx => Future.successful(()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tx is not used in a closure
nodeViewActorRef ! LocallyGeneratedTransaction(tx) | ||
(nodeViewActorRef ? LocallyGeneratedTransaction(tx)) | ||
.mapTo[ProcessingOutcome] | ||
.flatMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is also duplicated in WalletApiRoute, can be unified somehow?
memoryPool().process(tx, minimalState()) match { | ||
case (newPool, ProcessingOutcome.Accepted) => | ||
log.debug(s"Unconfirmed transaction $tx added to the memory pool") | ||
val newVault = vault().scanOffchain(tx) | ||
updateNodeView(updatedVault = Some(newVault), updatedMempool = Some(newPool)) | ||
context.system.eventStream.publish(SuccessfulTransaction(tx)) | ||
ProcessingOutcome.Accepted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can memoize processing result and thus eliminate 2 LoC
Nice comments, shared logic extracted to |
Closes #1768
P.S. I did the same for wallet API as there was a similar case