public abstract class MessageSerializer
extends java.lang.Object
Constructor and Description |
---|
MessageSerializer() |
Modifier and Type | Method and Description |
---|---|
abstract Message |
deserialize(java.nio.ByteBuffer in)
Reads a message from the given ByteBuffer and returns it.
|
abstract BitcoinSerializer.BitcoinPacketHeader |
deserializeHeader(java.nio.ByteBuffer in)
Deserializes only the header in case packet meta data is needed before decoding
the payload.
|
abstract Message |
deserializePayload(BitcoinSerializer.BitcoinPacketHeader header,
java.nio.ByteBuffer in)
Deserialize payload only.
|
abstract int |
getProtocolVersion()
Get the protocol version of this serializer.
|
abstract boolean |
isParseRetainMode()
Whether the serializer will produce cached mode Messages
|
abstract AddressV1Message |
makeAddressV1Message(byte[] payloadBytes,
int length)
Make an address message from the payload.
|
abstract AddressV2Message |
makeAddressV2Message(byte[] payloadBytes,
int length)
Make an address message from the payload.
|
Block |
makeBlock(byte[] payloadBytes)
Make a block from the payload, using an offset of zero and the payload
length as block length.
|
Block |
makeBlock(byte[] payloadBytes,
int length)
Make a block from the payload, using an offset of zero and the provided
length as block length.
|
abstract Block |
makeBlock(byte[] payloadBytes,
int offset,
int length)
Make a block from the payload, using an offset of zero and the provided
length as block length.
|
abstract Message |
makeBloomFilter(byte[] payloadBytes)
Make an filter message from the payload.
|
abstract FilteredBlock |
makeFilteredBlock(byte[] payloadBytes)
Make a filtered block from the payload.
|
abstract InventoryMessage |
makeInventoryMessage(byte[] payloadBytes,
int length)
Make an inventory message from the payload.
|
Transaction |
makeTransaction(byte[] payloadBytes)
Make a transaction from the payload.
|
Transaction |
makeTransaction(byte[] payloadBytes,
int offset)
Make a transaction from the payload.
|
abstract Transaction |
makeTransaction(byte[] payloadBytes,
int offset,
int length,
byte[] hash)
Make a transaction from the payload.
|
abstract void |
seekPastMagicBytes(java.nio.ByteBuffer in) |
abstract void |
serialize(Message message,
java.io.OutputStream out)
Writes message to to the output stream.
|
abstract void |
serialize(java.lang.String name,
byte[] message,
java.io.OutputStream out)
Writes message to to the output stream.
|
abstract MessageSerializer |
withProtocolVersion(int protocolVersion)
Create a new serializer with a specific protocol version.
|
public abstract MessageSerializer withProtocolVersion(int protocolVersion)
public abstract int getProtocolVersion()
public abstract Message deserialize(java.nio.ByteBuffer in) throws ProtocolException, java.io.IOException, java.lang.UnsupportedOperationException
ProtocolException
java.io.IOException
java.lang.UnsupportedOperationException
public abstract BitcoinSerializer.BitcoinPacketHeader deserializeHeader(java.nio.ByteBuffer in) throws ProtocolException, java.io.IOException, java.lang.UnsupportedOperationException
ProtocolException
java.io.IOException
java.lang.UnsupportedOperationException
public abstract Message deserializePayload(BitcoinSerializer.BitcoinPacketHeader header, java.nio.ByteBuffer in) throws ProtocolException, java.nio.BufferUnderflowException, java.lang.UnsupportedOperationException
BitcoinSerializer.deserializeHeader(java.nio.ByteBuffer)
.ProtocolException
java.nio.BufferUnderflowException
java.lang.UnsupportedOperationException
public abstract boolean isParseRetainMode()
public abstract AddressV1Message makeAddressV1Message(byte[] payloadBytes, int length) throws ProtocolException, java.lang.UnsupportedOperationException
ProtocolException
java.lang.UnsupportedOperationException
public abstract AddressV2Message makeAddressV2Message(byte[] payloadBytes, int length) throws ProtocolException, java.lang.UnsupportedOperationException
ProtocolException
java.lang.UnsupportedOperationException
public final Block makeBlock(byte[] payloadBytes) throws ProtocolException
ProtocolException
public final Block makeBlock(byte[] payloadBytes, int length) throws ProtocolException
ProtocolException
public abstract Block makeBlock(byte[] payloadBytes, int offset, int length) throws ProtocolException, java.lang.UnsupportedOperationException
ProtocolException
java.lang.UnsupportedOperationException
public abstract Message makeBloomFilter(byte[] payloadBytes) throws ProtocolException, java.lang.UnsupportedOperationException
ProtocolException
java.lang.UnsupportedOperationException
public abstract FilteredBlock makeFilteredBlock(byte[] payloadBytes) throws ProtocolException, java.lang.UnsupportedOperationException
ProtocolException
java.lang.UnsupportedOperationException
public abstract InventoryMessage makeInventoryMessage(byte[] payloadBytes, int length) throws ProtocolException, java.lang.UnsupportedOperationException
ProtocolException
java.lang.UnsupportedOperationException
public abstract Transaction makeTransaction(byte[] payloadBytes, int offset, int length, byte[] hash) throws ProtocolException, java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this serializer/deserializer
does not support deserialization. This can occur either because it's a dummy
serializer (i.e. for messages with no network parameters), or because
it does not support deserializing transactions.ProtocolException
public final Transaction makeTransaction(byte[] payloadBytes) throws ProtocolException, java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this serializer/deserializer
does not support deserialization. This can occur either because it's a dummy
serializer (i.e. for messages with no network parameters), or because
it does not support deserializing transactions.ProtocolException
public final Transaction makeTransaction(byte[] payloadBytes, int offset) throws ProtocolException
java.lang.UnsupportedOperationException
- if this serializer/deserializer
does not support deserialization. This can occur either because it's a dummy
serializer (i.e. for messages with no network parameters), or because
it does not support deserializing transactions.ProtocolException
public abstract void seekPastMagicBytes(java.nio.ByteBuffer in) throws java.nio.BufferUnderflowException
java.nio.BufferUnderflowException
public abstract void serialize(java.lang.String name, byte[] message, java.io.OutputStream out) throws java.io.IOException, java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this serializer/deserializer
does not support serialization. This can occur either because it's a dummy
serializer (i.e. for messages with no network parameters), or because
it does not support serializing the given message.java.io.IOException
public abstract void serialize(Message message, java.io.OutputStream out) throws java.io.IOException, java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this serializer/deserializer
does not support serialization. This can occur either because it's a dummy
serializer (i.e. for messages with no network parameters), or because
it does not support serializing the given message.java.io.IOException