Skip to content

Commit b995341

Browse files
authored
Merge pull request #5 from CortexFoundation/dev
robot multiple storage engine & service switch upgrade
2 parents 17fe4f9 + dc9ac02 commit b995341

File tree

6 files changed

+490
-40
lines changed

6 files changed

+490
-40
lines changed

backend/chaindb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func NewChainDB(config *params.Config) (*ChainDB, error) {
136136

137137
func (fs *ChainDB) Init() (err error) {
138138
fs.initOnce.Do(func() {
139-
if err = fs.initBlockNumber(); err != nil {
139+
if err = fs.InitBlockNumber(); err != nil {
140140
log.Error("Init block error", "err", err)
141141
//return err
142142
}
@@ -642,7 +642,7 @@ func (fs *ChainDB) initID() error {
642642
})
643643
}*/
644644

645-
func (fs *ChainDB) initBlockNumber() error {
645+
func (fs *ChainDB) InitBlockNumber() error {
646646
return fs.db.Update(func(tx *bolt.Tx) error {
647647
buk, err := tx.CreateBucketIfNotExists([]byte(CUR_BLOCK_NUM_ + fs.version))
648648
if err != nil {

cmd/main.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ func main() {
2424
if m, err := robot.New(cfg, true, false, false, nil); err != nil {
2525
panic(err)
2626
} else {
27-
m.SwitchService(robot.SRV_PRINT)
28-
2927
if err := m.Start(); err != nil {
3028
log.Error("start failed", "err", err)
3129
panic(err)
3230
}
3331
defer m.Stop()
3432

33+
//m.SwitchService(robot.SRV_RECORD)
3534
go func() {
36-
time.Sleep(5 * time.Second)
37-
m.SwitchService(robot.SRV_MODEL)
35+
for {
36+
m.SwitchService(robot.SRV_RECORD)
37+
time.Sleep(30 * time.Second)
38+
m.SwitchService(robot.SRV_MODEL)
39+
time.Sleep(30 * time.Second)
40+
//m.SwitchService(robot.SRV_RECORD)
41+
}
3842
}()
3943

4044
var c = make(chan os.Signal, 1)

doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
package robot
1818

1919
const (
20-
SRV_MODEL = 0
21-
SRV_PRINT = 99
20+
SRV_MODEL = 0
21+
SRV_RECORD = 99
2222
)

go.mod

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,65 @@ require (
88
github.com/CortexFoundation/torrentfs v1.0.51
99
github.com/google/uuid v1.3.0
1010
github.com/hashicorp/golang-lru v0.5.5-0.20221011183528-d4900dc688bf
11+
github.com/ucwong/golang-kv v1.0.22-0.20230702214711-bd3089dc589a
1112
go.etcd.io/bbolt v1.3.7
1213
)
1314

1415
require (
16+
github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0 // indirect
17+
github.com/beorn7/perks v1.0.1 // indirect
18+
github.com/bwmarrin/snowflake v0.3.0 // indirect
19+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
20+
github.com/cockroachdb/errors v1.10.0 // indirect
21+
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
22+
github.com/cockroachdb/pebble v0.0.0-20230707214756-fa85ec45a815 // indirect
23+
github.com/cockroachdb/redact v1.1.5 // indirect
24+
github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect
1525
github.com/deckarep/golang-set/v2 v2.3.0 // indirect
26+
github.com/dgraph-io/badger/v4 v4.0.2-0.20230612214140-c903578894e4 // indirect
27+
github.com/dgraph-io/ristretto v0.1.1 // indirect
28+
github.com/dustin/go-humanize v1.0.1 // indirect
29+
github.com/getsentry/sentry-go v0.22.0 // indirect
1630
github.com/go-ole/go-ole v1.2.6 // indirect
1731
github.com/go-stack/stack v1.8.1 // indirect
32+
github.com/gofrs/flock v0.8.1 // indirect
33+
github.com/gogo/protobuf v1.3.2 // indirect
34+
github.com/golang/glog v1.1.1 // indirect
35+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
36+
github.com/golang/protobuf v1.5.3 // indirect
37+
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
38+
github.com/google/flatbuffers v23.5.26+incompatible // indirect
1839
github.com/gorilla/websocket v1.5.0 // indirect
40+
github.com/hashicorp/golang-lru/v2 v2.0.4 // indirect
1941
github.com/holiman/uint256 v1.2.3-0.20230331162826-e42b95a00943 // indirect
42+
github.com/klauspost/compress v1.16.7 // indirect
43+
github.com/kr/pretty v0.3.1 // indirect
44+
github.com/kr/text v0.2.0 // indirect
45+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
46+
github.com/nutsdb/nutsdb v0.12.4-0.20230628143711-3843ce89fa65 // indirect
47+
github.com/pkg/errors v0.9.1 // indirect
48+
github.com/prometheus/client_golang v1.16.0 // indirect
49+
github.com/prometheus/client_model v0.4.0 // indirect
50+
github.com/prometheus/common v0.44.0 // indirect
51+
github.com/prometheus/procfs v0.11.0 // indirect
52+
github.com/rogpeppe/go-internal v1.11.0 // indirect
53+
github.com/rosedblabs/go-immutable-radix/v2 v2.0.1-0.20230614125820-f2a7bc058c90 // indirect
54+
github.com/rosedblabs/rosedb/v2 v2.2.1 // indirect
55+
github.com/rosedblabs/wal v1.2.0 // indirect
2056
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
57+
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
2158
github.com/tklauser/go-sysconf v0.3.11 // indirect
2259
github.com/tklauser/numcpus v0.6.1 // indirect
60+
github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb // indirect
61+
github.com/xujiajun/mmap-go v1.0.1 // indirect
62+
github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 // indirect
2363
github.com/yusufpapurcu/wmi v1.2.3 // indirect
64+
go.opencensus.io v0.24.0 // indirect
2465
golang.org/x/crypto v0.11.0 // indirect
66+
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
67+
golang.org/x/net v0.12.0 // indirect
2568
golang.org/x/sys v0.10.0 // indirect
69+
golang.org/x/text v0.11.0 // indirect
70+
google.golang.org/protobuf v1.31.0 // indirect
2671
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
2772
)

0 commit comments

Comments
 (0)