Package com.privatechain.core.mempool
Class MempoolSubmissionResult
java.lang.Object
com.privatechain.core.mempool.MempoolSubmissionResult
Immutable result of a
TransactionMempool.submitWithValidation(com.privatechain.core.model.Transaction, com.privatechain.core.builder.Blockchain) call.
Carries a boolean acceptance flag and, on rejection, the list of error messages
produced by the configured TransactionValidator
chain.
Usage
MempoolSubmissionResult result = mempool.submitWithValidation(tx, blockchain);
if (!result.isAccepted()) {
log.warn("Transaction rejected: {}", result.getRejectionReasons());
}
- Since:
- 1.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic MempoolSubmissionResultaccepted()Creates a result indicating the transaction was accepted into the mempool.booleanTwo results are equal if they have the same acceptance status and rejection reasons.Returns the list of human-readable rejection reasons.inthashCode()Returns a hash code consistent withequals(java.lang.Object).booleanReturnstrueif the transaction was accepted into the mempool.booleanReturnstrueif the transaction was rejected.static MempoolSubmissionResultCreates a result indicating the transaction was rejected.toString()Returns a human-readable string representation of this result.
-
Method Details
-
accepted
Creates a result indicating the transaction was accepted into the mempool.- Returns:
- a successful
MempoolSubmissionResult
-
rejected
Creates a result indicating the transaction was rejected.- Parameters:
reasons- non-null list of rejection messages (maybe empty)- Returns:
- a failed
MempoolSubmissionResult - Throws:
NullPointerException- if reasons is null
-
isAccepted
public boolean isAccepted()Returnstrueif the transaction was accepted into the mempool.- Returns:
trueon acceptance
-
isRejected
public boolean isRejected()Returnstrueif the transaction was rejected.Convenience inverse of
isAccepted().- Returns:
trueon rejection
-
getRejectionReasons
Returns the list of human-readable rejection reasons.Returns an empty list when the transaction was accepted.
- Returns:
- non-null, unmodifiable list of rejection messages
-
toString
Returns a human-readable string representation of this result. -
equals
Two results are equal if they have the same acceptance status and rejection reasons. -
hashCode
public int hashCode()Returns a hash code consistent withequals(java.lang.Object).
-