@@ -436,7 +458,12 @@ WARNING: independently of all these rules, each implementation must integrate it
...
@@ -436,7 +458,12 @@ WARNING: independently of all these rules, each implementation must integrate it
### CONNECT message
### CONNECT message
```json
```json
{} // TODO
{
"challenge": [...], // 32 bytes hash
"api_features": [...], // list of 4 integers corresponding to api_features (see in endpoint definition)
"connect_type": {...}, // see below
"peer_card": {...} // look at the peercard definition above
}
```
```
challenge := random hash generated by the sending node of the CONNECT message, the receiving node will then have to sign this challenge and then send this signature in its ACK message to prove that it has the corresponding private key to the public key it indicates.
challenge := random hash generated by the sending node of the CONNECT message, the receiving node will then have to sign this challenge and then send this signature in its ACK message to prove that it has the corresponding private key to the public key it indicates.
...
@@ -449,12 +476,42 @@ peer_card := See PeerCard above
...
@@ -449,12 +476,42 @@ peer_card := See PeerCard above
#### ConnectType type definition
#### ConnectType type definition
TODO
ConnectType represent the connection type. It can be:
- Incoming: *connect message sent when receiving an incoming websocket connection*
- Client: *connect message sent by a client*
- Server: *connect message sent between nodes for a normal connection*
- Sync: *connect message sent for a synchronization request*
- SyncAskChunk: *connect message sent for a chunk request*
Incoming, Client and Server are represented by a string.
Each node must sign the challenge of the other to prove that it's in possession of the private key corresponding to the public key under which it identifies.
Each node must sign the challenge of the other to prove that it's in possession of the private key corresponding to the public key under which it identifies.
...
@@ -465,7 +522,7 @@ The message is already signed at the container level, so there is no need to rep
...
@@ -465,7 +522,7 @@ The message is already signed at the container level, so there is no need to rep
TODO
TODO
If its valued, the `member_proof` field must contain a signature of the challenge* send by other node in their CONNECT message.
If it is valued, the `member_proof` field must contain a signature of the challenge* send by other node in their CONNECT message.
_*It's the remote challenge for the signatory, and the local challenge for the verifier._
_*It's the remote challenge for the signatory, and the local challenge for the verifier._
...
@@ -479,11 +536,13 @@ LOW_FLOW_DEMAND := The sender node of this message indicates that it's behind a
...
@@ -479,11 +536,13 @@ LOW_FLOW_DEMAND := The sender node of this message indicates that it's behind a
### OK message
### OK message
In most cases, the OK message is empty (=3 zero-bytes), it simply indicates that the remote node accepts the connection establishment. If the local node has also sent an OK message, then it considers the connection as fully established.
In most cases, the OK message is empty, it simply indicates that the remote node accepts the connection establishment. If the local node has also sent an OK message, then it considers the connection as fully established.
But sometimes the OK message can also transmit additional informations :
But sometimes the OK message can also transmit additional informations :
```json
```json
{} // TODO
{
"prefix": ... // null or non-zero integer
}
```
```
prefix := In ws2p v2, member nodes have the option of not publicly communicating their prefix. It will only reveal their prefix to the node of their choice among those with which they establish a connection. For example, a member node may decide to share its prefix only with other member nodes of the same key.
prefix := In ws2p v2, member nodes have the option of not publicly communicating their prefix. It will only reveal their prefix to the node of their choice among those with which they establish a connection. For example, a member node may decide to share its prefix only with other member nodes of the same key.
...
@@ -492,7 +551,15 @@ If this field is zero, it means that the remote node does not want to reveal its
...
@@ -492,7 +551,15 @@ If this field is zero, it means that the remote node does not want to reveal its
#### SYNC_INFO message
#### SYNC_INFO message
```json
```json
{} // TODO
{
"chunk_size": 500,
"target_blockstamp": {
"id": 0,
"hash": [...] // 32 bytes hash
},
"milestones": [...], // list of 32 bytes hashes
"peer_cards": [...] // list of peercards
}
```
```
chunk_size := defines the size of the block used in milestones. A 1000-block chunk is a good compromise between efficiency of compression and duration of transfer
chunk_size := defines the size of the block used in milestones. A 1000-block chunk is a good compromise between efficiency of compression and duration of transfer
...
@@ -506,7 +573,7 @@ peer_cards := see [definition of binary peer card](#peer-card-binary-format)
...
@@ -506,7 +573,7 @@ peer_cards := see [definition of binary peer card](#peer-card-binary-format)