Skip to content

This module writes, reads, validates, and copies chains of microstar messages. Each message contains the hash of the previous.

License

Notifications You must be signed in to change notification settings

microstar-derp/microstar-chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

microstar-chain

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.

Conventions

settings object.

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)

settings must contain:

  • db - This is a leveldb.
  • keys - This is a keypair generated by microstar-crypto
  • indexes - This is an object of level-librarian indexes, to be used when writing documents to the db.

indexes

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.

API

mChain.read(settings, query)

This method simply aliases read from level-librarian.

mChain.write(settings, callback)

This method returns a pull-stream sink that writes a chain of messages to the db.

Messages

  • 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 as type.

mChain.copy(settings, initial, callback)

  • initial - This is the message thatr

About

This module writes, reads, validates, and copies chains of microstar messages. Each message contains the hash of the previous.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published