Package org.bitcoinj.core
Class BaseMessage
- java.lang.Object
-
- org.bitcoinj.core.BaseMessage
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
AddressMessage
,Block
,BloomFilter
,EmptyMessage
,FeeFilterMessage
,FilteredBlock
,GetBlocksMessage
,HeadersMessage
,ListMessage
,Ping
,Pong
,RejectMessage
,Transaction
,VersionMessage
public abstract class BaseMessage extends java.lang.Object implements Message
A Message is a data structure that can be serialized/deserialized using the Bitcoin serialization format. Specific types of messages that are used both in the blockchain, and on the wire, are derived from this class.Instances of this class are not safe for use by multiple threads.
-
-
Constructor Summary
Constructors Constructor Description BaseMessage()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
bitcoinSerializeToStream(java.io.OutputStream stream)
Serializes this message to the provided stream.int
messageSize()
Return the size of the serialized message.byte[]
serialize()
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
-
Methods inherited from interface org.bitcoinj.core.Message
bitcoinSerialize, getMessageSize, unsafeBitcoinSerialize
-
-
-
-
Method Detail
-
serialize
public final byte[] serialize()
Serialize this message to a byte array that conforms to the bitcoin wire protocol.
-
bitcoinSerializeToStream
protected abstract void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Throws:
java.io.IOException
-
messageSize
public int messageSize()
Return the size of the serialized message. Note that if the message was deserialized from a payload, this size can differ from the size of the original payload.- Specified by:
messageSize
in interfaceMessage
- Returns:
- size of this object when serialized (in bytes)
-
-