Package com.norswap.nanoeth.data
Class Hash
java.lang.Object
com.norswap.nanoeth.data.Hash
- All Implemented Interfaces:
RLPLayoutable
- Direct Known Subclasses:
MerkleRoot
@Wrapper public class Hash extends Object implements RLPLayoutable
Represents a 256-bit (32 bytes) Keccak hash.
- See Also:
Hashing
-
Field Summary
Fields Modifier and Type Field Description byte[]
bytes
The bytes making up the hash.static Hash
EMPTY_SEQ_HASH
Hash of the empty RLP sequence.static Hash
ZERO
A hash composed of only zero bytes. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
int
hashCode()
static Hash
parse(RLP rlp)
RLP
rlpLayout()
Returns the RLP layout for the object.String
toFullHexString()
The hex-string representation of this hash, including leading 0 if any, as perByteUtils.toFullHexString(byte[])
.String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.norswap.nanoeth.rlp.RLPLayoutable
rlpEncode, rlpHexString
-
Field Details
-
ZERO
A hash composed of only zero bytes. -
EMPTY_SEQ_HASH
Hash of the empty RLP sequence.Can notably be compared against the uncle hash of a block header to see if the block has any uncles.
-
bytes
public final byte[] bytesThe bytes making up the hash.
-
-
Constructor Details
-
Hash
-
Hash
Creates a hash from a hex string (e.g. 0x123).If the post-0x part of the hex string is not 64 characters long, the hash will be padded with zeroes at the start so that it is 32 bytes long.
-
-
Method Details
-
parse
- Throws:
RLPParsingException
-
toFullHexString
The hex-string representation of this hash, including leading 0 if any, as perByteUtils.toFullHexString(byte[])
. -
rlpLayout
Description copied from interface:RLPLayoutable
Returns the RLP layout for the object.- Specified by:
rlpLayout
in interfaceRLPLayoutable
-
equals
-
hashCode
public int hashCode() -
toString
-