Clients send messages to peers in order to interact with the blockchain. These can be divided into general peer messages, and consensus methods used by validators for forging blocks.
Messages are written using the Semux Message Encoding format.
Messages send the code byte first, then the parameters in order
Message:
- ip (string)
- port (int)
- networkVersion (short)
- clientId (string)
- peerId (string)
- latestBlockNumber (long)
- capabilities size (int)
- capabilities[] (string[])
Code: 0x01
Initiate a connection with a peer. No messages will be accepted until after this handshake is done.
Message:
- peer (Peer)
- timestamp (long)
- signature (byte[])
Code: 0x02
Respond to a Hello message indicating successful connection.
Message:
- peer (Peer)
- timestamp (long)
- signature (byte[])
Code: 0x03
Request a reply from the peer to ensure connection is still valid.
Message:
- timestamp (long)
Code: 0x04
Respond to a Ping message.
Message:
- timestamp (long)
Code: 0x00
Inform a peer of disconnection. Reasons can include too many peers, invalid handshake, or other.
Message:
- reason (byte)
Code: 0x05
Request peers of the peer.
Message: None.
Code: 0x06
Send a list of current peers.
Message:
- size (int) (number of nodes)
- ip (string)
- port (int)
Code: 0x07
Propagate a transaction from mempool.
Message:
- hash (byte[])
- networkId (byte)
- type (byte)
- to (byte[])
- amount (long)
- fee (long)
- nonce (long)
- timestamp (long)
- data (byte[])
- signature (byte[])
for CALL and CREATE types
- gas (long)
- gasPrice (long)
Code: 0x30
Request a block header.
Message:
- number (long)
Code: 0x31
Send a block header.
Message:
- hash (byte[])
- number (long)
- coinbase (byte[])
- previous hash (byte[])
- timestamp (long)
- transaction root (byte[])
- result root (byte[])
- state root (byte[])
- data (byte[])
These are messages passed as part of the BFT
Code: 0x40
Code: 0x41
Code: 0x42
A block proposal.
Code: 0x43
A vote on the current phase.