-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
52 lines (36 loc) · 836 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"os"
"strconv"
"github.com/syndtr/goleveldb/leveldb/filter"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/enixdark/dag-block/lib"
"github.com/enixdark/dag-block/lib/dag"
"github.com/enixdark/dag-block/lib/db"
"github.com/enixdark/dag-block/lib/db/leveldb"
)
func main() {
//var err error
os.RemoveAll("./data/db")
option := dag_leveldb.LevelOption{
Options: &opt.Options{
Filter: filter.NewBloomFilter(10),
},
Path: "./data/db",
}
db := db.NewDatabase("leveldb", option)
dg := lib.DAG{
Db: &db,
Worker: make(chan string),
}
dg.Memory = dag.NewDAG()
dg.Db.Db.Connection()
defer dg.Db.Db.Close()
for i := 1; i < 100; i++ {
vertex := dag.NewVertex(strconv.Itoa(i), nil)
dg.Memory.AddVertex(vertex)
dg.Insert(vertex)
}
fmt.Println(dg.List("4"))
}