• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

bregydoc/blackholeDB: BlackholeDB is a simple distributed key-value DB based on ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

bregydoc/blackholeDB

开源软件地址:

https://github.com/bregydoc/blackholeDB

开源编程语言:

Go 100.0%

开源软件介绍:

Black Hole DB (WIP)

BlackHoleDB (or only HoleDB) is a conceptual Key-Value distributed Database. HoleDB uses IPFS as decentralized filesystem, and BadgerDB as store for local key value pairs.

Warning: BlackHole is work in progress, please don't use it in production.

How it Works

BlackHoleDB creates an encrypted file into IPFS filesystem and this return an Qm name (the decentralized path), this Qm path is saved into BadgerDB instance as value where the key is the initial key choose. When you want get your value from the distributed web BlackHoleDB get the Qm linked your key (from BadgerDB) and with this Qm path HoleDB gets the encrypted file from IPFS and finally it decrypted it.

Example code:

options := blackhole.DefaultOptions
db, err := blackhole.Open(options)
if err != nil {
	panic(err)
}

key := "answer"

err = db.Set(key, []byte("Hello World, from BlackHoleDB"))
if err != nil {
	panic(err)
}

data, err := db.Get(key)
if err != nil {
	panic(err)
}

fmt.Println("Answer: ", string(data))
// Answer: Hello World, from BlackHoleDB

About Options Configuration

You can configure the params of your blackhole instance, you can see the struct related above.

type Options struct {
	PrivateKey         []byte // Your encoding key
	EndPointConnection string // Your IPFS Node endpoint
	PrincipalNode      string // Useless now (WIP)

	LocalDBDir      string // Your Local Badger DB
	LocalDBValueDir string // Your Local Badger DB
}

The default configuration is:

var DefaultOptions *Options = &Options{
	LocalDBDir:         "/tmp/badger",
	LocalDBValueDir:    "/tmp/badger",
	EndPointConnection: "localhost:5001",
}
// Note: You need to define your privateKey like this:
// opts.PrivateKey, _ = hex.DecodeString("44667768254d593b7ea48c3327c18a651f6031554ca4f5e3e641f6ff1ea72e98")

Basic Usage Example

package main

import (
	"fmt"
	"github.com/bregydoc/blackholeDB"
)

func main() {
	db, err := blackhole.Open(blackhole.DefaultOptions)
	if err != nil {
		panic(err)
	}

	defer db.Close()

	err = db.Set("answer", []byte("42"))
	if err != nil {
		panic(err)
	}

	answer, err := db.Get("answer")
	if err != nil {
		panic(err)
	}

	fmt.Println("The answer of the life is: ", string(answer))
	// The answer of the life is:  42
}

TODO

  • Improve the security
  • Make Blackhole a metaDB. Save all param configurations on Distributed web (IPFS)
  • Use MsgPack to serialize the data
  • Create an ORM layer to save complex structs

Contributing to BlackHoleDB

BlackHoleDB is an open source project and contributors are welcome!




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap