Skip to content

Instantly share code, notes, and snippets.

@d3x0r
Created April 18, 2018 23:47
Show Gist options
  • Save d3x0r/9dbbb5d75504b83971bafb75972db07b to your computer and use it in GitHub Desktop.
Save d3x0r/9dbbb5d75504b83971bafb75972db07b to your computer and use it in GitHub Desktop.
A no-op storage driver for gun, in case gun has no other storage; at least one ack from a storage device is required for the engine to work....
Gun.on('opt', function(ctx){
const ACK_ = '@';
const SEQ_ = '#';
var gun = ctx.gun;
this.to.next(ctx);
ctx.on('put', function(at) {
this.to.next(at);
ctx.on('in', {[ACK_]: at[SEQ_], gun:gun, ok: 1});
});
ctx.on('get', function(at){
this.to.next(at);
ctx.on('in', {[ACK_]: at[SEQ_], gun:gun, err: "no data"});
});
})
@d3x0r
Copy link
Author

d3x0r commented Apr 18, 2018

Untested; but it should basically work.... I can work with you to fix it if you find it totally flawed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment