2.1.1 • Published 5 months ago
picorepo v2.1.1
_ . _ _ ._ _ _
|_)|(_(_)|(/_|_)(_)
| |
Block storage
The repo is part of picostack
This is a low-level blockstore for picofeeds that stores consistent chains using a fast access scheme.
- uses abstract-leveldown for storage backends
Use
$ npm install picorepo levelup memdown
import { Repo } from 'picorepo'
import { Feed } from 'picofeed'
const db = new MemoryLevel('pico', {
keyEncoding: 'buffer',
valueEncoding: 'buffer'
})
const repo = new Repo(db)
// Generate an crypto identity consisting of a public and secret key
const { pk, sk } = Feed.signPair()
const feed = new PicoFeed()
feed.append('Alpha', sk)
feed.append('Beta', sk)
feed.append('Gamma', sk)
const numberAccepted = await repo.merge(feed) // => 3 blocks
// Retrieve feed by Author
const alt1 = await repo.loadHead(pk)
// Retrive feed by block-signature
const alt2 = await repo.resolveFeed(feed.first.sig)
Graphviz support
To avoid brain-leakage I've added a tool that renders dot-files to easier inspect which blocks are stored and where their tags are located.
import { writeFileSync } from 'node:fs'
import { inspect } from 'picorepo/dot'
// generate graph as string
const dotString = await inspect(repo)
// dump as file
writeFileSync('repo.dot', dotString)
# use xdot to view it
xdot repo.dot
# or render as png
dot -Gcenter="true" -Gsize="8,8\!" -Gdpi=100 -Kdot -Tpng -O *.dot
Changelog
2.0.0 2023-04-30
- ported to picofeed v4
1.3.1 2022-08-02
- added experimental mode 'allowDetached'
1.3.0 Eons later
- added optional graphviz/dot generator
- added index for chain-id
- added async repo.listFeeds()
- changed repo.writeBlock() to use batch ops.
1.0.0 first release
Contributing
By making a pull request, you agree to release your modifications under the license stated in the next section.
Only changesets by human contributors will be accepted.
License
2021 🄯 Tony Ivanov
2.1.1
5 months ago
2.1.0
5 months ago
1.4.6
1 year ago
2.0.3
1 year ago
2.0.2
1 year ago
2.0.1
1 year ago
2.0.0
1 year ago
1.4.5
2 years ago
1.4.4
2 years ago
1.4.3
2 years ago
1.3.3
2 years ago
1.2.4
2 years ago
1.3.2
2 years ago
1.2.3
2 years ago
1.4.0
2 years ago
1.3.1
2 years ago
1.3.0
2 years ago
1.2.2
2 years ago
1.2.0
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.1.3
2 years ago
1.2.1
2 years ago
1.1.2
2 years ago
1.0.0
3 years ago