Skip to content

Commit

Permalink
Merge pull request #47 from paulkernfeld/master
Browse files Browse the repository at this point in the history
Slight documentation streamlining in README
  • Loading branch information
dominictarr committed Jan 3, 2016
2 parents a748da1 + f8072e6 commit 5844fd9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ another master node and have master nodes replicate each way.

## Implementing Custom Scuttlebutts

The user must inherit from `Scuttlebutt` and provide an implementation of `history()` and `applyUpdate()`.
A custom Scuttlebutt is a data model that inherits from `Scuttlebutt`. It must provide an implementation of `history()` and `applyUpdate()`.

See [r-value](https://github.com/dominictarr/r-value) for a demonstration of the simplest possible Scuttlebutt, one that replicates a a single value.

### Scuttlebutt#history(sources)

Expand All @@ -179,6 +181,8 @@ The array MUST be in order by timestamp.

### Scuttlebutt#applyUpdate (update)

Each update is of the form `[change, timestamp, source]` (see [Protocol](#Protocol) below).

Possibly apply a given update to the subclasses model.
Return 'true' if the update was applied. (See scuttlebutt/model.js
for an example of a subclass that does not apply every update.)
Expand Down Expand Up @@ -233,7 +237,7 @@ Add an event listener.

### scuttlebutt/model

A replicateable `Model` object.
A replicateable `Model` object, a simple key-value store.

``` js
var Model = require('scuttlebutt/model')
Expand Down Expand Up @@ -314,16 +318,16 @@ for a simple example implementation.

`sign(update)` should sign the `update` with the instance's private key.
`verify(update, cb)` should verify the update, using public key associated with the
`source` field in the update. Verification may be asyncronous. `verify` must callback
`source` field in the update. Verification may be asynchronous. `verify` must callback
`cb(err, boolean)` where boolean indicates whether or not the signature is valid.
Only callback in error in the most extreme circumstances.
If there was no known key for the required source then that should be treated as a
verification failure. If it is not possible to reach the key database (or whatever)
then the request should be retried until it is available.

> Note: although the API supports asyncronous verification,
> Note: although the API supports asynchronous verification,
> it's probably a good idea to load keys into memory so that messages can be verified
> and signed syncronously.
> and signed synchronously.
`createId()` returns a new id for the current node. This is used in the example security
implementation to return a id that is a hash of the public key. This makes it impossible
Expand Down

0 comments on commit 5844fd9

Please sign in to comment.