Class MessageCodec

java.lang.Object
com.privatechain.network.rpc.MessageCodec

public final class MessageCodec extends Object
Encodes and decodes wire-protocol messages exchanged between blockchain nodes.

MessageCodec is responsible for the serialization layer of the P2P protocol. All messages are framed as UTF-8 JSON with a type discriminator field. This makes the protocol human-readable and debuggable while meeting the portability requirements of the private-blockchain library.

Message format

Every message follows a simple envelope:


 {
   "type": "BLOCK",          // one of the MessageType enum values
   "senderId": "nodeId...",  // originating node ID
   "payload": { ... }        // type-specific JSON object
 }
 

Supported message types

Thread safety

Jackson's ObjectMapper is thread-safe after configuration; this class is safe for concurrent use by multiple threads.

Since:
1.0.0