dat-replicator
Replicate a dat instance to another one (in a smart way) using nothing but streams
npm install dat-replicator
Usage
Replicating is a simple as piping a few streams
var replicator =var r1 =var r2 =var send = r1var rcvd = r2send // will sync dat1 to dat2
Real world example
First setup a dat instance to receive data. Using tcp this could look like
var replicator =var net =var r = // datReceive is a dat instancenet
Then setup another that instance to send the data. Again using tcp
var r = // datSend is a dat instancevar socket = netsocket
Thats it! All of the changes that datSend
have and that datReceive
doesn't will
be inserted into datReceive
.
Metadata
Per default metadata (the change count etc) is exchanged over the stream as well. If for some reason you already have this do
var send = r1var rcvd = r2send
This will disable the metadata exchange
License
MIT