Skip to content

Commit

Permalink
Merge pull request #5 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
robot multiple storage engine & service switch upgrade
  • Loading branch information
ucwong authored Jul 10, 2023
2 parents 17fe4f9 + dc9ac02 commit b995341
Show file tree
Hide file tree
Showing 6 changed files with 490 additions and 40 deletions.
4 changes: 2 additions & 2 deletions backend/chaindb.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func NewChainDB(config *params.Config) (*ChainDB, error) {

func (fs *ChainDB) Init() (err error) {
fs.initOnce.Do(func() {
if err = fs.initBlockNumber(); err != nil {
if err = fs.InitBlockNumber(); err != nil {
log.Error("Init block error", "err", err)
//return err
}
Expand Down Expand Up @@ -642,7 +642,7 @@ func (fs *ChainDB) initID() error {
})
}*/

func (fs *ChainDB) initBlockNumber() error {
func (fs *ChainDB) InitBlockNumber() error {
return fs.db.Update(func(tx *bolt.Tx) error {
buk, err := tx.CreateBucketIfNotExists([]byte(CUR_BLOCK_NUM_ + fs.version))
if err != nil {
Expand Down
12 changes: 8 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ func main() {
if m, err := robot.New(cfg, true, false, false, nil); err != nil {
panic(err)
} else {
m.SwitchService(robot.SRV_PRINT)

if err := m.Start(); err != nil {
log.Error("start failed", "err", err)
panic(err)
}
defer m.Stop()

//m.SwitchService(robot.SRV_RECORD)
go func() {
time.Sleep(5 * time.Second)
m.SwitchService(robot.SRV_MODEL)
for {
m.SwitchService(robot.SRV_RECORD)
time.Sleep(30 * time.Second)
m.SwitchService(robot.SRV_MODEL)
time.Sleep(30 * time.Second)
//m.SwitchService(robot.SRV_RECORD)
}
}()

var c = make(chan os.Signal, 1)
Expand Down
4 changes: 2 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
package robot

const (
SRV_MODEL = 0
SRV_PRINT = 99
SRV_MODEL = 0
SRV_RECORD = 99
)
45 changes: 45 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,65 @@ require (
github.com/CortexFoundation/torrentfs v1.0.51
github.com/google/uuid v1.3.0
github.com/hashicorp/golang-lru v0.5.5-0.20221011183528-d4900dc688bf
github.com/ucwong/golang-kv v1.0.22-0.20230702214711-bd3089dc589a
go.etcd.io/bbolt v1.3.7
)

require (
github.com/DataDog/zstd v1.5.6-0.20230622172052-ea68dcab66c0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.10.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230707214756-fa85ec45a815 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect
github.com/deckarep/golang-set/v2 v2.3.0 // indirect
github.com/dgraph-io/badger/v4 v4.0.2-0.20230612214140-c903578894e4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/getsentry/sentry-go v0.22.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/flatbuffers v23.5.26+incompatible // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.4 // indirect
github.com/holiman/uint256 v1.2.3-0.20230331162826-e42b95a00943 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/nutsdb/nutsdb v0.12.4-0.20230628143711-3843ce89fa65 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rosedblabs/go-immutable-radix/v2 v2.0.1-0.20230614125820-f2a7bc058c90 // indirect
github.com/rosedblabs/rosedb/v2 v2.2.1 // indirect
github.com/rosedblabs/wal v1.2.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/ucwong/go-ttlmap v1.0.2-0.20221020173635-331e7ddde2bb // indirect
github.com/xujiajun/mmap-go v1.0.1 // indirect
github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)
Loading

0 comments on commit b995341

Please sign in to comment.