Package com.privatechain.core.exception
Class BlockValidationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.privatechain.core.exception.BlockchainException
com.privatechain.core.exception.BlockValidationException
- All Implemented Interfaces:
Serializable
Thrown when a
Block fails validation during Blockchain.addBlock().
Possible causes include:
- The block's hash does not satisfy the consensus difficulty target
block.previousHashdoes not match the current chain tip's hash- The block's Merkle root does not match the computed root of its transactions
- The block's stored hash does not match a fresh computation (corruption)
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBlockValidationException(String message, Block block) Constructs an exception with a detail message and the offending block.BlockValidationException(String message, Throwable cause, Block block) Constructs an exception with a detail message, cause, and the offending block. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
BlockValidationException
Constructs an exception with a detail message and the offending block.- Parameters:
message- human-readable description of why the block was rejectedblock- the block that failed validation (maybe null)
-
BlockValidationException
Constructs an exception with a detail message, cause, and the offending block.- Parameters:
message- human-readable description of why the block was rejectedcause- the underlying exceptionblock- the block that failed validation (maybe null)
-
-
Method Details
-
getBlock
Returns the block that triggered this exception.- Returns:
- the invalid block, or
nullif not available
-