-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from XDagger/develop
Sync Dev branch
- Loading branch information
Showing
207 changed files
with
7,819 additions
and
9,751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Message Encoding | ||
Xdagj network messages format. | ||
|
||
## Types | ||
|
||
### boolean | ||
1 bit | ||
|
||
### long | ||
8 bytes | ||
|
||
### int | ||
4 bytes | ||
|
||
### byte[] | ||
First write the number of bytes using [VLQ](https://en.wikipedia.org/wiki/Variable-length_quantity), then write each byte. | ||
|
||
### string | ||
First write the number of bytes using [VLQ](https://en.wikipedia.org/wiki/Variable-length_quantity), then write each byte of the string. | ||
|
||
## VLQ | ||
Variable length quantity. This encoding allows for writing both large and small numbers in an efficient manner. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Network Protocol | ||
|
||
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 XDAGJ [XDAGJ_Message_Encoding](./XDAGJ_Message_Encoding_en.md) format. | ||
|
||
Messages send the code byte first, then the parameters in order | ||
|
||
|
||
## Standard Message Objects | ||
|
||
### Peer | ||
|
||
Message: | ||
- ip (string) | ||
- port (int) | ||
- networkVersion (short) | ||
- clientId (string) | ||
- peerId (string) | ||
- latestBlockNumber (long) | ||
- capabilities size (int) | ||
- capabilities[] (string[]) | ||
|
||
## P2P Messages | ||
|
||
- [0x00, 0x0f] Reserved for p2p basics | ||
|
||
### Disconnect | ||
|
||
Code: 0x00 | ||
|
||
Inform a peer of disconnection. Reasons can include too many peers, invalid handshake, or other. | ||
|
||
Message: | ||
- reason (byte) | ||
|
||
### Hello | ||
|
||
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[]) | ||
|
||
### World | ||
|
||
Code: 0x02 | ||
|
||
Respond to a Hello message indicating successful connection. | ||
|
||
Message: | ||
- peer (Peer) | ||
- timestamp (long) | ||
- signature (byte[]) | ||
|
||
### Ping | ||
|
||
Code: 0x03 | ||
|
||
Request a reply from the peer to ensure connection is still valid. | ||
|
||
Message: | ||
- timestamp (long) | ||
|
||
### Pong | ||
|
||
Code: 0x04 | ||
|
||
Respond to a Ping message. | ||
|
||
Message: | ||
- timestamp (long) | ||
|
||
## Consensus Messages | ||
|
||
- [0x10, 0x1f] Reserved for node | ||
|
||
### BLOCKS_REQUEST(0x10) | ||
### BLOCKS_REPLY(0x11) | ||
### SUMS_REQUEST(0x12) | ||
### SUMS_REPLY(0x13) | ||
### BLOCKEXT_REQUEST(0x14) | ||
### BLOCKEXT_REPLY(0x15) | ||
### BLOCK_REQUEST(0x16) | ||
### RECEIVE_BLOCK(0x17) | ||
### NEW_BLOCK(0x18) | ||
### SYNC_BLOCK(0x19) | ||
### SYNCBLOCK_REQUEST(0x1A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.