If this documentation is at all unclear, please do not hestitate to file an issue. Ease of implementation is the primary goal of this project.
This module creates chains of messages. Each message (except for the first) contains the hash of the previous message. Each message is also signed. This allows microstar-chain to verify that a given chain is contigous and that it comes from a certain node.
Most of the methods in this module, and the rest of microstar take a settings
object as the first argument. This object contains things that are unlikely to change on a per-call basis. Calling microstar-chain
with a settings object will return all the same methods, with settings
pre-filled.
var mChain = require('microstar-chain')
mChain.write(settings, template, callback)
// OR
mChain = mChain(settings)
mChain.write(template, callback)
db
- This is a leveldb.keys
- This is a keypair generated bymicrostar-crypto
indexes
- This is an object oflevel-librarian
indexes, to be used when writing documents to the db.
This module requires some indexes to be present in the db. These indexes are available as mChain.indexes
. Add these indexes to the settings object that you pass to microstar modules.
This method simply aliases read
from level-librarian
.
This method returns a pull-stream
sink that writes a chain of messages to the db.
content
- The content of the message. This can be any JSON.type
- The type of the message. Please follow a convention of prefixing the message type with the name of your module like this:<name of module>:<type of message>
.chain_id
- An identifier for the chain. Namespace this in the same way astype
.
initial
- This is the message thatr