|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.bitcoin.core.Message
public abstract class Message
A Message is a data structure that can be serialized/deserialized using both the Bitcoin proprietary serialization format and built-in Java object serialization. Specific types of messages that are used both in the block chain, and on the wire, are derived from this class.
| Nested Class Summary | |
|---|---|
static class |
Message.LazyParseException
|
| Field Summary | |
|---|---|
protected byte[] |
bytes
|
protected byte[] |
checksum
|
protected int |
cursor
|
protected int |
length
|
static int |
MAX_SIZE
|
protected int |
offset
|
protected NetworkParameters |
params
|
protected boolean |
parsed
|
protected boolean |
parseLazy
|
protected boolean |
parseRetain
|
protected int |
protocolVersion
|
protected boolean |
recached
|
static int |
UNKNOWN_LENGTH
|
| Constructor Summary | |
|---|---|
protected |
Message()
This exists for the Java serialization framework to use only. |
| Method Summary | |
|---|---|
protected void |
adjustLength(int newArraySize,
int adjustment)
|
byte[] |
bitcoinSerialize()
Returns a copy of the array returned by unsafeBitcoinSerialize(), which is safe to mutate. |
void |
bitcoinSerialize(OutputStream stream)
Serialize this message to the provided OutputStream using the bitcoin wire format. |
void |
ensureParsed()
In lazy parsing mode access to getters and setters may throw an unchecked LazyParseException. |
Sha256Hash |
getHash()
This method is a NOP for all classes except Block and Transaction. |
int |
getMessageSize()
This should be overridden to extract correct message size in the case of lazy parsing. |
NetworkParameters |
getParams()
Network parameters this message was created with. |
boolean |
isCached()
used for unit testing |
boolean |
isParsed()
used for unit testing |
boolean |
isRecached()
|
protected void |
maybeParse()
Ensure the object is parsed if needed. |
protected abstract void |
parseLite()
Perform the most minimal parse possible to calculate the length of the message. |
protected void |
unCache()
To be called before any change of internal values including any setters. |
byte[] |
unsafeBitcoinSerialize()
Serialize this message to a byte array that conforms to the bitcoin wire protocol. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_SIZE
public static final int UNKNOWN_LENGTH
protected transient int offset
protected transient int cursor
protected transient int length
protected transient byte[] bytes
protected transient boolean parsed
protected transient boolean recached
protected final transient boolean parseLazy
protected final transient boolean parseRetain
protected transient int protocolVersion
protected transient byte[] checksum
protected NetworkParameters params
| Constructor Detail |
|---|
protected Message()
| Method Detail |
|---|
protected abstract void parseLite()
throws ProtocolException
ProtocolExceptionprotected void maybeParse()
public void ensureParsed()
throws ProtocolException
ProtocolExceptionprotected void unCache()
protected void adjustLength(int newArraySize,
int adjustment)
public boolean isParsed()
public boolean isCached()
public boolean isRecached()
public byte[] bitcoinSerialize()
unsafeBitcoinSerialize(), which is safe to mutate.
If you need extra performance and can guarantee you won't write to the array, you can use the unsafe version.
public byte[] unsafeBitcoinSerialize()
public final void bitcoinSerialize(OutputStream stream)
throws IOException
stream -
IOExceptionpublic Sha256Hash getHash()
public int getMessageSize()
public NetworkParameters getParams()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||