Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagged hashes #64

Merged
merged 17 commits into from
Nov 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 6 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ since v0.
``` js
// create a scuttlebutt instance and add a message to it.

var ssb = require('secure-scuttlebutt/create')(path)
var pull = require('pull-stream')
var keys = require('ssb-keys').loadOrCreateSync(pathToSecret)

var ssb = require('secure-scuttlebutt/create')('/tmp/ssb1')

//create a feed.
//this represents a write access / user.
Expand Down Expand Up @@ -51,36 +54,6 @@ pull(
console.log(ary)
})
)

// create a server for replication.

var net = require('net')
var toStream = require('pull-stream-to-stream')

net.createServer(function (stream) {
// secure-scuttlebutt uses pull-streams so
// convert it into a node stream before piping.
stream.pipe(toStream(ssb.createReplicationStream())).pipe(stream)
}).listen(1234)

//create another database to replicate with:

var ssb2 = require('secure-scuttlebutt/create')(path2)
var feed2 = ssb2.createFeed()
//follow the key we created before.
feed.add({
type: 'pub', address: {host: HOST, port: 1234}
}, function () { ... })

feed2.add({
type: 'follow',
follows: {$feed: feed.id, $rel: 'follows'}
})

// replicate from the server.
// this will pull the messages by feed1 into this database.
var stream = net.connect(1234)
stream.pipe(toStream(ssb2.createReplicationStream())).pipe(stream)
```

## Concepts
Expand Down Expand Up @@ -109,26 +82,8 @@ request the chain for that id, since the latest item you know about.

### Replication

secure-scuttlebutt is based on [Scuttlebutt](http://www.cs.cornell.edu/home/rvr/papers/flowgossip.pdf)
Except that there is no way for old messages to be obsoleted by new message.
All messages are eventually replicated - secure-scuttlebutt is eventually consistent.

Perhaps the simplest way to look at it is as many simultaneous
master-slave replications. The master appends to a log,
giving each message a monotonically increasing sequence number.
When the slave connects to the master and requests the messages
that came after the sequence number they received last time.

Now, each node is the master of their own feed, so scuttlebutt
replication is just like doing many simultanious master-slave replications.

Since messages are signed, and replication is eventually consistent,
it does not matter if A receives B's messages via C, they can verify
B's messages offline (i.e, when A is out of contact with B)

However, no networking is provided by this module, so that it's
useful as a replicatable database - however, a gossip based networking
layer is in development.
replication has been moved into the networking layer:
[scuttlebot](https://github.com/pfraze/scuttlebot)

### References

Expand Down Expand Up @@ -177,13 +132,6 @@ the id of the feed (which is the hash of the feeds public key)

the key pair for this feed.

### SecureScuttlebutt#follow (id)

Mark `id`'s feed as replicated. this instance will request
data created by `id` when replicating.
see [createReplicationStream](#createReplicationStream)
The id must be the hash of id's public key.

### SecureScuttlebutt#getPublicKey(id, cb)

Retrive the public key for `id`, if it is in the database.
Expand Down Expand Up @@ -218,14 +166,6 @@ only stream messages with sequence numbers greater than `seq`.
if `live` is true, the stream will be a
[live mode](https://github.com/dominictarr/pull-level#example---reading)

### SecureScuttlebutt#createReplicationStream()

Create a duplex pull-stream that speak's secure-scuttlebutt's replication protocol.
this will be a pull-stream so you will need to use it with
[pull-stream-to-stream](https://github.com/dominictarr/pull-stream-to-stream)

This should be in the duplex style, when connecting as either a server or a client.

## License

MIT
92 changes: 0 additions & 92 deletions api.js

This file was deleted.

184 changes: 0 additions & 184 deletions codec.js

This file was deleted.

Loading