DenkMitDB is a distributed key-value database built heavily on IPFS, using a Merkle Tree as a consistency controller. It includes consensus and access controllers to ensure the database remains safe and consistent across distributed nodes. It has capabilities to delete records.
- Distributed Storage: Utilizes IPFS for decentralized data storage.
- Consistency Control: Employs Merkle Tree structures to maintain data consistency.
- Consensus Mechanism: Ensures all nodes agree on the current state of the database.
- Access Control: Manages permissions and security for database access.
To set up DenkMitDB, follow these steps:
-
Clone the repository:
git clone https://github.com/askarzh/denkmitdb.git cd denkmitdb
-
Install dependencies:
npm install
After installation, you can start using DenkMitDB by following these steps:
-
Import modules:
import { gossipsub } from "@chainsafe/libp2p-gossipsub"; import { noise } from "@chainsafe/libp2p-noise"; import { yamux } from "@chainsafe/libp2p-yamux"; import { identify } from "@libp2p/identify"; import { tcp } from "@libp2p/tcp"; import { createHelia } from "helia"; import { createLibp2p } from "libp2p"; import { createDenkmitDatabase, createIdentity } from "../functions";
-
Initialize libp2p & Helia:
const libp2pOptions = { addresses: { listen: ["/ip4/0.0.0.0/tcp/0"] }, transports: [tcp()], connectionEncryption: [noise()], streamMuxers: [yamux()], services: { identify: identify(), pubsub: gossipsub({ emitSelf: true }), }, }; const libp2p = await createLibp2p(libp2pOptions); const helia = await createHelia({ libp2p });
-
Create new Database Identity and new Database:
const identity = await createIdentity({ helia, name: "user" }); const db = await createDenkmitDatabase("test", { helia, identity }); console.log("Database address: ", db.id);
-
Add new data to Database:
await db.set("key1", { value: "value1" }); await db.set("key2", { value: "value2" }); for await (const e of db.iterator()) { console.log(e); }
-
Retrieve data from Database:
const value1 = await db.get("key1"); console.log("Value 1: ", value1);
-
Close Database
await db.close(); await helia.stop();
We welcome contributions! Please fork the repository and submit pull requests. For major changes, please open an issue to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
- IPFS
- Libp2p
- TypeScript
- Node.js
For more information, please contact the project maintainer at askar@zhakenov.pro.