core state management for nickslist
npm install nickslist-core
var nickslist = require('nickslist-core')
var memdb = require('memdb')
var hyperlog = require('hyperlog')
var log = hyperlog(memdb(), {
valueEncoding: 'json'
})
var manager = nickslist.manager(nickslist.makeKeys(), log)
manager.on('post', p => {
console.log('i see a post!', p.value.body)
})
manager.post({ hello: 'hi' }, (err, node) => {
manager.reply(node, { whats: 'up'})
})
returns an object { signKeypair, encryptKeypair }
(see hyperreal)
pass keys
into nickslist.manager(keys, hyperlog)
keys
are from nickslist.makeKeys()
hyperlog
is any hyperlog-like object
msg
is an object, which we will post verified (but not encrypted)
cb(err, node)
will pass back the node that was added to the hyperlog (converted to in cleartext)
node
is some node, to which we will encrypt our reply
msg
is an object
cb(err, node)
will pass back the node that was added to the hyperlog (converted to in cleartext). node.links
will refer to the node we're replying to
cb(post)
called whenever a post comes in over the hyperlog (including our own)
cb(err)
called whenever there's an error putting something on the hyperlog. (same err
will be passed through list.reply()
' and list.post()
's cb.
BSD