Class MempoolSubmissionResult

java.lang.Object
com.privatechain.core.mempool.MempoolSubmissionResult

public final class MempoolSubmissionResult extends Object
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 Details

    • accepted

      public static MempoolSubmissionResult accepted()
      Creates a result indicating the transaction was accepted into the mempool.
      Returns:
      a successful MempoolSubmissionResult
    • rejected

      public static MempoolSubmissionResult rejected(List<String> reasons)
      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()
      Returns true if the transaction was accepted into the mempool.
      Returns:
      true on acceptance
    • isRejected

      public boolean isRejected()
      Returns true if the transaction was rejected.

      Convenience inverse of isAccepted().

      Returns:
      true on rejection
    • getRejectionReasons

      public List<String> 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

      public String toString()
      Returns a human-readable string representation of this result.
      Overrides:
      toString in class Object
      Returns:
      a string like "MempoolSubmissionResult[accepted=true]" or "MempoolSubmissionResult[rejected, reasons=[...]]"
    • equals

      public boolean equals(Object obj)
      Two results are equal if they have the same acceptance status and rejection reasons.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if equal
    • hashCode

      public int hashCode()
      Returns a hash code consistent with equals(java.lang.Object).
      Overrides:
      hashCode in class Object
      Returns:
      hash code