Code from the NordicJS talk on how to build GUN!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mark Nadal 13a3ea0c18
2 years ago
ad-hoc first 4 years ago
com first 4 years ago
graph first 4 years ago
key first 4 years ago
resolution first 4 years ago
storage Update store.js 3 years ago
test first 4 years ago batch note 4 years ago
dup.js 2 years ago
get.js first 4 years ago
ham.js first 4 years ago

Porting GUN

Please see the docs and watch the 30min NordicJS tech talk first.

Note: This folder is currently missing a package.json , if you want to run the NodeJS samples you'll need to install ws and likely a few other packages.

Implementation order, follow along with the video:

  1. Port /com into your language of choice, test that it is working against the browser.
  2. Then port the changes in /ad-hoc into your system, including the deduplication code, test against the browser.
  3. Then port the changes in /graph, test against browser, etc.
  4. Port /resolution, including the CRDT conflict resolution algorithm, etc., test multiple times against browser, etc.
  5. Port /key, etc. its in-memory lookup, etc. test against browser.

Now you're done! You have an in-memory, websocket+JSON port of GUN in your language! Any existing GUN app* (note: see batching comment below) should be able to point to your peer and things will work, except for long term storage.

If you decide to port /storage please note two things:

  1. Use the latest Radix Storage Engine code from GUN's main repo.
  2. It is still currently work-in-progress and thus maintain bugs.

Feel free to watch the NordicJS follow-up talk on doing distributed load testing against your server. Note that /test contains a duplicate of the code, you can ignore these duplicates.

Any questions? Hit me up on !

Note: This does not implement an API for whatever language you port GUN to. The javascript API so far has been the hardest thing to build, not GUN itself. (The API is considered separate from GUN's wire spec protocol.)

*Batching Note: Wire spec sends JSON messages as msg however most existing adapters have a batching mechanism that sounds JSON as [msg, msg, msg], this is trivial to fix with something like this:

onSocketReceive(data) {
  if('[' === data[0]){
    return JSON.parse(data).forEach(msg => onSocketReceive(msg));
  var msg = JSON.parse(data);
  // ... continue as normal