News for hackers. Stuff that matters.
Re:Show HN: Gun database – 100k ops/sec in IE6 on 2GB Atom CPU by yellowapple on Saturday December 24, 2016 @08:46PM (#13252451)
All the CP v. AP and algorithmic discussion aside, I'd be really interested in some actual concrete documentation on the actual peer-to-peer protocol involved (preferably without having to resort to testing my cursory understanding of Javascript by reading the source code). I'd be very interested in trying my hand at some alternate implementations (this sort of thing looks perfect for an Erlang/Elixir project), but if my only hope is to reverse-engineer the reference implementation, I'd be far more inclined to just stick to CouchDB or Barrel.
Re:Show HN: Gun database – 100k ops/sec in IE6 on 2GB Atom CPU by marknadal on Monday December 26, 2016 @05:24AM (#13257756)
Great comment!

The P2P protocol's base case is an ad-hoc mesh network (how the messaging between peers works is explained here: https://github.com/amark/gun/wiki/Mesh-Network-Messaging-Alg... ).

Initial connections are handled statelessly, both peers exchange blobs of the requested/subscribed data to make sure they are in sync (not out of date / old / stale). On the wire, this is a GET command.

Then the connection becomes stateful, and only the changes/deltas/diff of data are pushed over the network, thus allowing for realtime updates. Over ther wire, this is a PUT command.

All data is represented as a graph (whether key/value, table, relational, document, or graph itself).

And that is about it! Other than, of course, the AP aspects and the hybrid vector/lexical/timestamp CRDT for conflict resolution. The architecture is genuinely quite simple, intended to be the foundation for more complex data structures to be built on top (other CRDTs, or DAGs, simple linked lists, etc.).

There is a half baked "How to port GUN" guide here: https://github.com/amark/gun/wiki/porting-gun .