Skip to content

Commit

Permalink
Merge pull request #305 from XDagger/develop
Browse files Browse the repository at this point in the history
Sync Dev branch
  • Loading branch information
LucasMLK authored Mar 15, 2024
2 parents b689c0d + decfdd0 commit 801e1ea
Show file tree
Hide file tree
Showing 207 changed files with 7,819 additions and 9,751 deletions.
22 changes: 22 additions & 0 deletions docs/XDAGJ_Message_Encoding_en.md
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.
92 changes: 92 additions & 0 deletions docs/XDAGJ_Network_Protocol_en.md
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)
6 changes: 3 additions & 3 deletions docs/XDAGJ_RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
| **xdag_getRewardByNumber** | Height | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getRewardByNumber\",\"params\":[\"1000\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"1024.000000000"} | Used to return the reward of some height |
| **xdag_sendRawTransaction** | BlockData(String) <br /> "raw data of the block" | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data " <br /> {\"jsonrpc\":\"2.0\",\"method\":\"xdag_sendRawTransaction\",\"params\": <br />[\"00000000000000002863550000000000feffed9d7d01000000000000000000005d453264dfe0f2dcd0b09fff8db233af668bf7aa873176470000000064000000defb03f1a99ce1498f19afa5b0c752d5409bb2fdc4e087e10000000064000000506bc1dc099358e5137292f4efdd57e400f29ba5132aa5d12b18dac1c1f6aaba12dfa82f55245fb4a8a8ddbbe2eb970f80347741ff0907e8844630004981eb230a329c87c <br />2736c8067e7a15190587502e5bf761e4f919aaf84ce62b3f1f5cffc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <br />00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <br />0000000000000000000000000000000000000000000000000000(TxBlockRawDate)\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"MWdnWaYpLMwlazfFwmk4onmNE82JVFTB(BlockHash)"} | Used to send transactions |
| **xdag_netType** | Null | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netType\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"testnet"} | Used to return the net type xdag running for |
| **xdag_netConnectionList** | Null | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netConnectionList\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":[{"nodeAddress":"localhost:8002","connectTime":1654431183389,"inBound":1744,"outBound":1101},{"nodeAddress":"localhost:61179","connectTime":1654431099718,"inBound":7949,"outBound":5623}]}Used to return the net conn list | Used to return the net connect list |
| **xdag_poolConfig** | Null | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_poolConfig\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"poolIp":"127.0.0.1","poolPort":7001,"nodeIp":"127.0.0.1","nodePort":8001,"globalMinerLimit":8192,"maxConnectMinerPerIp":256,"maxMinerPerAccount":256,"poolFeeRation":"5.0","poolRewardRation":"5.0","poolDirectRation":"5.0","poolFundRation":"5.0"}} | Used to get pool config |
| **xdag_updatePoolConfig** | poolRewardRation(String) poolDirectRation(String) poolFundRation(String) poolFeeRation(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_updatePoolConfig\",\"params\":[{\"poolFeeRation\":\"12\",\"poolRewardRation\":\"11\",\"poolDirectRation\":\"13\",\"poolFundRation\":\"14.2\"},\"password\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"Success"} | Used to update award configuration |
| **xdag_netConnectionList** | Null | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netConnectionList\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":[{"nodeAddress":"127.0.0.1:55067","connectTime":1751104356352,"inBound":0,"outBound":0}]} Used to return the net conn list | Used to return the net connect list |
| **xdag_poolConfig** | **Abandon in XDAGj V0.7.0, move to XDAGPool-Go** | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_poolConfig\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"poolIp":"127.0.0.1","poolPort":7001,"nodeIp":"127.0.0.1","nodePort":8001,"globalMinerLimit":8192,"maxConnectMinerPerIp":256,"maxMinerPerAccount":256,"poolFeeRation":"5.0","poolRewardRation":"5.0","poolDirectRation":"5.0","poolFundRation":"5.0"}} | Used to get pool config |
| **xdag_updatePoolConfig** | **Abandon in XDAGj V0.7.0, move to XDAGPool-Go** | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_updatePoolConfig\",\"params\":[{\"poolFeeRation\":\"12\",\"poolRewardRation\":\"11\",\"poolDirectRation\":\"13\",\"poolFundRation\":\"14.2\"},\"password\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"Success"} | Used to update award configuration |



Loading

0 comments on commit 801e1ea

Please sign in to comment.