Updating README

master
Sander Ferdinand 6 years ago
parent 7e144fe61d
commit 1aac995389
No known key found for this signature in database
GPG Key ID: 7BBC83D7A8810AAB

@ -1,8 +1,6 @@
# py-levin
The Levin network protocol is an implementation of peer-to-peer (P2P) communications found in a large number of cryptocurrencies, including basically any cryptocurrency that is a descendant from the CryptoNote project.
This module provides the building blocks to create and parse Levin packets.
> The Levin network protocol is an implementation of peer-to-peer (P2P) communications found in a large number of cryptocurrencies, including basically any cryptocurrency that is a descendant from the CryptoNote project.
## Example usage:
@ -27,6 +25,30 @@ Ask a node for it's peer list, sorted on `last_seen`:
[...]
```
### Some notes
A Levin header (33 bytes) looks like this:
1. `u_int64` - A levin signature. `01 21 01 01 01 01 01 01` also known as 'Benders nightmare'.
2. `u_int64` - Payload size as an indicator of how many bytes to read from the network.
3. `bool` - Recipient should return data.
4. `u_int32` - The command. `e9 03 00 00` - Possible commands: `1001`, `1007`, etc. See `constants.py`.
5. `int32` - Return code.
6. `u_int32` - Flags.
5. `u_int32` - Protocol version. Usually `01`
The payload that comes after that is a serialized Boost struct, which can be found
in the Monero codebase, e.g: [cryptonote_protocol_defs.h](https://github.com/monero-project/monero/blob/58ce16d4d91518b674a5d46419809f56f71d9114/src/cryptonote_protocol/cryptonote_protocol_defs.h).
The terminology for a (possible nested collection) of structs is called a `Section()` in this module.
For the actual serialization from the perspective of Monero, check out [portable_storage_to_bin.h](https://github.com/monero-project/monero/blob/58ce16d4d91518b674a5d46419809f56f71d9114/contrib/epee/include/storages/portable_storage_to_bin.h)
For deserialization look at `Reader.read_storage_entry()` and `Reader.read()`.
Data is almost always in little-endian byte order, with the exception of keys (strings) for values in serialized structs.
Lastly, this module is presented as 'best effort' and, for example, does not guarantee that all Levin data types are supported.
### References
- [Monerujo](https://github.com/m2049r/xmrwallet/tree/master/app/src/main/java/com/m2049r/levin)
- [Monero codebase](https://github.com/monero-project/monero)
@ -34,7 +56,7 @@ Ask a node for it's peer list, sorted on `last_seen`:
### Thanks
- m2049r
- Big thanks to [m2049r](https://github.com/m2049r/) for his Java implementation of Levin on Monerujo (remote node finder).
- notmike
### License

Loading…
Cancel
Save