-
-
Save khodzha/36eb72671a087e5e3ae2e0e8b03d55f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const util = require('util'); | |
const ram = require('random-access-memory') | |
const hypercore = require('hypercore') | |
var feed = hypercore((filename) => { | |
return ram(); | |
}, {valueEncoding: 'utf-8'}); | |
const append = util.promisify(feed.append.bind(feed)); | |
const get = util.promisify(feed.get.bind(feed)); | |
const proof = util.promisify(feed.proof.bind(feed)); | |
const s = async () => { | |
await append('hi'); | |
await append('ola'); | |
await append('ahoj'); | |
await append('salut'); | |
var feed2 = hypercore((filename) => { | |
return ram(); | |
}, feed.key, {valueEncoding: 'utf-8', secretKey: feed.secretKey}); | |
const get2 = util.promisify(feed2.get.bind(feed2)); | |
const put2 = util.promisify(feed2.put.bind(feed2)); | |
for (let i = 0; i < 4; ++i) { | |
console.log('================'); | |
data = await get(i); | |
pr = await proof(i); | |
console.log(i, "PROOF:\n", pr); | |
console.log('================'); | |
await put2(i, data, pr); | |
let data2 = await get2(i); | |
} | |
} | |
s(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment