Files
@ 6a0ab4fe9f5e
Branch filter:
Location: Morevna/protocol.md - annotation
6a0ab4fe9f5e
2.5 KiB
text/markdown
changed naming to snake case. sadly no love for camel case in this world
13603ac261f1 1755ac6857bd ccbe369ce439 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd ccbe369ce439 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 13603ac261f1 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd ccbe369ce439 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd ccbe369ce439 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd 1755ac6857bd | # Protocol v0.1 #
[Communication protocol proposal. Not yet fully implemented and still expected to change.]
Nodes communicate by exchanging messages through network sockets. Basic message format is simple:
json-length: ABC
bin-length: DEF
{... JSON payload ...}
... binary payload ...
`ABC` is the JSON payload length (decimal integer), `DEF` is the binary payload length. JSON payload always contains a "command" field.
The client sends a request (a message) and the server answers with a response (another message).
## Commands ##
### <a name="init"></a>init ###
Initiates communication between the client and the server. Checks that the nodes can meaningfully talk to each other.
#### Params ####
- [(int) major, (int) minor, (int) tiny] version version: program version. Both the client and the server are to check for compatibility with their partner.
- {push, pull} action: what the client desires to do
- (str) filename: name of the file to be synchronized
- (int) blockSize
- (int) blockCount
#### Responses ####
- [init](#r-init)
- [deny](#deny)
### <a name="req"></a>req ###
Requests hashes or a data chunk from the server.
#### Params ####
- {hash, data} dataType
hash
- [(int) i0, ...] index: list of requested node keys from the HashTree
data
- [(int) i0, ...] index: list of requested data blocks from the data file. Returns blockSize bytes starting at blockSize * i.
#### Responses ####
- [send](#send)
- [err](#err)
### <a name="send"></a>send ####
Sends data. Can be a client action or a response to a request.
#### Params ####
- {hash, data} dataType
- index: see [req](#req)
#### Responses ####
- [ack](#ack)
- [err](#err)
### <a name="end"></a>end ###
Cease talking and close the connection.
#### Params ####
- {push} (optional) action: unlocks the server's dirty lock
#### Responses ####
- end
## Responses ##
### <a name="r-init"></a>init ###
See [the init command](#init). If the client doesn't like server's protocol version, it is free to [end](#end) the connection.
#### Params ####
- [(int) major, (int) minor, (int) tiny] version
### <a name="deny"></a>deny ###
The server refuses connection. It might be busy, corrupted or incompatible.
#### Params ####
- (int) retry: suggested delay in seconds before another attempt at connection
- (int) status
- (str) msg
### <a name="ack"></a>ack ###
Everything is alright, but the server has nothing better to say.
### <a name="err"></a>err ###
Something bad happened.
#### Params ####
- (str) msg
|