Skip to content

Repository files navigation

 _ __ (_) ___ ___ ___ | |_ __ _ ___ | | __
| '_ \ | | / __|/ _ \ / __|| __|/ _` | / __|| |/ /
| |_) || || (__| (_) |\__ \| |_| (_| || (__ | <
| .__/ |_| \___|\___/ |___/ \__|\__,_| \___||_|\_\
|_| network without super node

If you stash your entire Backend inside Frontend you get "Blockend".

This is a toolkit to build P2P application cores, using emepheral states.

Why do we need yet another consensus engine in 202x? Well this one provides a non-token based approach to decentralization (and also it runs in frontend/-user device with finite resources).

The General Idea In a picoverse nothing is permanent, blocks dissapear, chains corrupt, states across nodes differ. The global state exists but is considered "non computable", so each node attempts to gather and forward as many valid block sequences as it can hold, discarding lesser along the way. In bc-terms pico could be called an intricate mempool that gives you fine control over computing states that "could be".

This kit exposes a higher level API to quickly design and test what ever consensus you imagine. If you stumble on a local state that you wish to persist as truth, you can of course copy the pico-blocks to what ever medium you like. Their format is binary and quite space-efficient.

Update 2024 After a lot of iterations picostore 3.x is starting to emerge. In hindsight I would have liked to rename some components like stack => core-kit and store => block-engine, it makes more sense.

core components

  • picofeed Ultra-portable secure feed/chain-of-blocks
  • picostore block engine w/ garbarge collector.
  • piconet Internet Protocol redesigned for P2P, provides a stateless and easy to use alternative to network streams.
  • Modem56 hyperswarm to pico-net converter.
  • nuro A pure functional approach to reactive store pattern, design your own reactive neural pathways, completely framework agnostic.
  • HyperSimulator Run dat/hyper-apps in an in-memory swarm and watch the chaos unfold.
  • picorepo Lightweight persistent block store ontop of leveldb/leveljs.

Quickstart

Use the project template:

npx degit telamon/pico-template my-project

Check the README.md in the generated folder.

usage

Extend SimpleKernel when starting new.

// blockend.jsimport{SimpleKernel}from'picostack'const{ decodeBlock }=SimpleKernelclassKernelextendsSimpleKernel{constructor(db){super(db)// Register reducer - see picostore docsthis.store.register({name: 'clock',// slice nameinitialValue: 0,// initial statefilter({ block }){// network-consensusconst{ type, time }=decodeBlock(block.body)if(type!=='tick')returntrue// silent ignoreif(time>Date.now())return'TimestampFromFuture'},reducer({ block }){// mutate stateconst{ time }=decodeBlock(block.body)returntime}})}// Create actionasynccreateTick(){constfeed=awaitthis.createBlock('tick',// BlockType:string{time: Date.now()}// Payload:any)returnfeed.last.sig// block-id}}asyncfunctionmain(){// Spawn 2 peersconstalice=newKernel(memdown())awaitalice.boot()constbob=newKernel(memdown())awaitbob.boot()// Attach state-observersalice.store.on('clock',state=>console.log('Alice:',state))bob.store.on('clock',state=>console.log('Bob:',state))// Wire upalice.spawnWire()(bob.spawnWire())awaitalice.createTick()// Both kernels logs new state}main().catch(console.error)

Ad

| __ \ Help Wanted! | | | | | |
| | | | ___ ___ ___ _ __ | |_| | __ _| |__ ___ ___ ___
| | | |/ _ \/ __/ _ \ '_ \| __| | / _` | '_ \/ __| / __|/ _ \
| |__| | __/ (_| __/ | | | |_| |___| (_| | |_) \__ \_\__ \ __/
|_____/ \___|\___\___|_| |_|\__|______\__,_|_.__/|___(_)___/\___|
If you're reading this it means that the docs are missing or in a bad state.
Writing and maintaining friendly and useful documentation takes
effort and time.
__How_to_Help____________________________________.
| |
| - Open an issue if you have questions! |
| - Star this repo if you found it interesting |
| - Fork off & help document <3 |
| - Say Hi! :) https://discord.gg/8RMRUPZ9RS |
|.________________________________________________|

ZEN.md

Word of advice to the brave, this code was written mainly during tired off-hours, it is intristically minimalistic and mostly dependency free.

Best code, no code:

  • standard - no semis
  • spaces until tabs.
  • Uint8Array > Buffer
  • JSDoc types on plebic APIs

That's it.. sorry.

License

AGPL-3.0-or-later

2022 © Tony Ivanov

About

Web8.0 Framework, 0% Backend, 10'000% Frontend

Topics

Resources

Stars

72 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages