mirror of
https://gitlab.com/bluesky-community1/decentralized-ecosystem.git
synced 2025-02-19 21:30:49 +01:00
77 lines
4.6 KiB
Markdown
77 lines
4.6 KiB
Markdown
# Gun
|
|
|
|
Gun is a distributed database with a graph structure. Related libraries include a constellation of tools for merging conflicting data and handling routing and security.
|
|
|
|
In GunDB's graph store, entries are [JSON objects under UUID keys](https://gun.eco/docs/Porting-GUN). Data is stored in browser localStorage by default, with backup "supernode" servers to ensure persistence. Peers connect to other peers, and choose what data to synchronize and persist.
|
|
|
|
### Identity
|
|
|
|
Gun's SEA module provides the capability to create a [public/private keypair](https://github.com/amark/gun/wiki/Auth) for a user.
|
|
|
|
### Network structure
|
|
|
|
Gun transfers data between peers. When a client puts something in a graph, a message is sent to the network and other clients that have subscribed to that data pick it up and update their state. Those who are offline will eventually receive those updates.
|
|
|
|
Gun uses a flooding algorithm for message propagation, called [DAM](https://gun.eco/docs/DAM) (Daisy-chain ad-hoc mesh-network). DAM's API allows for the swapping out of transport layers (websockets, WebRTC, etc). A proposed future [routing](https://gun.eco/docs/Routing) protocol, the [AXE protocol](https://web.stanford.edu/~nadal/A-Decentralized-Data-Synchronization-Protocol.pdf), includes a mechanism for monetization through bandwidth-based payments.
|
|
|
|
### Data
|
|
|
|
Gun saves data two ways, in a client browser's localStorage, and through [RAD](https://gun.eco/docs/RAD), a storage adaptor that stores data on disk using a radix tree. Clients subscribe to the data they need from the "superpeer", a persistent node storing data on disk that should be run with most applications to ensure availability of data when other browser-based peers are offline. Superpeers are servers running node.js and persisting data on disk. Clients may serve the data they have to other clients as well.
|
|
|
|
Peers connect to graphs relevant to their application's logic. There is no universally shared graph across the network.
|
|
|
|
GunDB uses CRDTs (Conflict-free Replicated Data Types). Conflicts are handled by a [conflict resolution algorithm](https://gun.eco/docs/Conflict-Resolution-with-Guns) that uses lexical sort. Gun is eventually consistent, not strongly consistent, meaning that peers will eventually converge upon the last updated value.
|
|
|
|
Gun focuses on mutability by not using an append-only CRDT, instead allowing insertion and deletion into the graph. [Deletion](https://stackoverflow.com/questions/37758618/how-to-delete-data-in-gun-db) works by inserting `null` at the deleted node, de-referencing it.
|
|
|
|
#### Filtering
|
|
|
|
There is a [GraphQL](https://github.com/brysgo/graphql-gun) API for the gun p2p graph database.
|
|
|
|
### Privacy and Access Control
|
|
|
|
Privacy and access control can be built on top of GunDB's graph by encrypting data for the intended user. Gun's encryption utilities, [SEA](https://gun.eco/docs/SEA) (Security, Encryption, and Authorization), intend to make it easier to add private space to applications.
|
|
|
|
For access control, cryptographic keys are assigned to roles, groups, or data points. This information is either used to derive a shared ECDH secret to decrypt (read), or to load collaborative multi-writer edits (signed).
|
|
|
|
Iris, a decentralized social network building on Gun, has a [library](https://github.com/irislib/iris-lib) for encrypted GUN channels and contact list management.
|
|
|
|
### Interoperablity
|
|
|
|
Plugins, such as backup storage on centralized databases or file systems, can be used to extend GUN.
|
|
|
|
### Scalability
|
|
|
|
### Metrics
|
|
|
|
- 11K+ [github](https://github.com/amark/gun) stars
|
|
- 10M ~ 30M monthly [downloads](https://www.jsdelivr.com/package/npm/gun)
|
|
|
|
### Monetization
|
|
|
|
The GUN protocol is developed by a VC-funded company.
|
|
|
|
### Implementations
|
|
|
|
- [HackerNoon](https://hackernoon.com/state-of-hacker-noon-2019-2020-8w1ls3axx) integrated Gun for annotations
|
|
- [Meething](https://meething.space/) is a Mozilla backed secure & decentralized video conferencing that uses GUN
|
|
- [Party](https://party.lol/), an encrypted messaging browser extension, uses Gun
|
|
- [Notabug](https://notabug.io/t/notabug/comments/59382d2a08b7d7073415b5b6ae29dfe617690d74/welcome-to-notabug), a decentralized Reddit clone, uses Gun
|
|
- [DTube](https://d.tube/) uses GunDB for messaging
|
|
- [Iris](https://irislib.github.io/), a web-of-trust based social network, is built on Gun
|
|
|
|
### Related
|
|
|
|
Comparisons can be made to other databases designed for p2p use cases:
|
|
|
|
[OrbitDB](https://github.com/orbitdb/orbit-db) - see under [IPFS.md](IPFS.md)
|
|
|
|
[HyperDB](https://github.com/mafintosh/hyperdb) - see under [hypercore.md](hypercore.md)
|
|
|
|
[KappaDB](https://github.com/kappa-db)
|
|
|
|
### Links
|
|
|
|
[Site](gun.eco)
|
|
[Documentation Clarification](https://github.com/amark/gun/issues/597)
|