Rm db.Info, rm go-iden3-core dependency

Rm db.Info, rm go-iden3-core dependency, update version of
go-iden3-crypto
This commit is contained in:
arnaucube
2020-12-18 11:58:02 +01:00
parent e5a3d7e049
commit 5c7c03eca1
8 changed files with 48 additions and 110 deletions

View File

@@ -19,7 +19,6 @@ type Storage interface {
Get([]byte) ([]byte, error)
List(int) ([]KV, error)
Close()
Info() string
Iterate(func([]byte, []byte) (bool, error)) error
}

View File

@@ -1,8 +1,6 @@
package leveldb
import (
"encoding/json"
"github.com/iden3/go-merkletree/db"
log "github.com/sirupsen/logrus"
"github.com/syndtr/goleveldb/leveldb"
@@ -35,42 +33,6 @@ func NewLevelDbStorage(path string, errorIfMissing bool) (*Storage, error) {
return &Storage{ldb, []byte{}}, nil
}
type storageInfo struct {
KeyCount int
ClaimCount int
}
// Info implements the method Info of the interface db.Storage
func (l *Storage) Info() string {
snapshot, err := l.ldb.GetSnapshot()
if err != nil {
return err.Error()
}
keycount := 0
claimcount := 0
iter := snapshot.NewIterator(nil, nil)
for iter.Next() {
if iter.Value()[0] == byte(1) {
claimcount++
}
keycount++
}
iter.Release()
if err := iter.Error(); err != nil {
return err.Error()
}
json, _ := json.MarshalIndent(
storageInfo{
KeyCount: keycount,
ClaimCount: claimcount,
},
"", " ",
)
return string(json)
}
// WithPrefix implements the method WithPrefix of the interface db.Storage
func (l *Storage) WithPrefix(prefix []byte) db.Storage {
return &Storage{l.ldb, db.Concat(l.prefix, prefix)}

View File

@@ -25,11 +25,6 @@ func NewMemoryStorage() *Storage {
return &Storage{[]byte{}, kvmap}
}
// Info implements the method Info of the interface db.Storage
func (m *Storage) Info() string {
return "in-memory"
}
// WithPrefix implements the method WithPrefix of the interface db.Storage
func (m *Storage) WithPrefix(prefix []byte) db.Storage {
return &Storage{db.Concat(m.prefix, prefix), m.kv}

View File

@@ -1,8 +1,6 @@
package pebble
import (
"encoding/json"
"github.com/cockroachdb/pebble"
"github.com/iden3/go-merkletree/db"
log "github.com/sirupsen/logrus"
@@ -32,36 +30,6 @@ func NewPebbleStorage(path string, errorIfMissing bool) (*Storage, error) {
return &Storage{rdb, []byte{}}, nil
}
type storageInfo struct {
KeyCount int
ClaimCount int
}
// Info implements the method Info of the interface db.Storage
func (p *Storage) Info() string {
keycount := 0
claimcount := 0
err := p.Iterate(func(key []byte, value []byte) (bool, error) {
if value[0] == byte(1) {
claimcount++
}
keycount++
return true, nil
})
if err != nil {
return err.Error()
}
json, _ := json.MarshalIndent(
storageInfo{
KeyCount: keycount,
ClaimCount: claimcount,
},
"", " ",
)
return string(json)
}
// WithPrefix implements the method WithPrefix of the interface db.Storage
func (p *Storage) WithPrefix(prefix []byte) db.Storage {
return &Storage{p.pdb, db.Concat(p.prefix, prefix)}