aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-11 09:02:21 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit42577929821c56994da7a950f9646ac3f54ce4c6 (patch)
treee9860bd074ec5aa87508c39ad7a68ba630c57d83 /dex
parente9798937a5978224bc54dd5627bdfa5b9ca3340f (diff)
downloadgo-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.tar
go-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.tar.gz
go-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.tar.bz2
go-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.tar.lz
go-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.tar.xz
go-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.tar.zst
go-tangerine-42577929821c56994da7a950f9646ac3f54ce4c6.zip
core: add reset to dkg private key db (#355)
* vendor: sync to latest core * core: dkg private key db
Diffstat (limited to 'dex')
-rw-r--r--dex/db/db.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/dex/db/db.go b/dex/db/db.go
index 2930400b2..5cb809055 100644
--- a/dex/db/db.go
+++ b/dex/db/db.go
@@ -69,27 +69,24 @@ func (d *DB) PutBlock(block coreTypes.Block) error {
return nil
}
-func (d *DB) HasDKGPrivateKey(round uint64) (bool, error) {
- return rawdb.HasCoreDKGPrivateKey(d.db, round)
-}
-
-func (d *DB) GetDKGPrivateKey(round uint64) (coreDKG.PrivateKey, error) {
- key := rawdb.ReadCoreDKGPrivateKey(d.db, round)
+func (d *DB) GetDKGPrivateKey(round, reset uint64) (coreDKG.PrivateKey, error) {
+ key := rawdb.ReadCoreDKGPrivateKey(d.db, round, reset)
if key == nil {
return coreDKG.PrivateKey{}, coreDb.ErrDKGPrivateKeyDoesNotExist
}
return *key, nil
}
-func (d *DB) PutDKGPrivateKey(round uint64, key coreDKG.PrivateKey) error {
- has, err := d.HasDKGPrivateKey(round)
- if err != nil {
- return err
- }
- if has {
+func (d *DB) PutDKGPrivateKey(round, reset uint64, key coreDKG.PrivateKey) error {
+ _, err := d.GetDKGPrivateKey(round, reset)
+ if err == nil {
return coreDb.ErrDKGPrivateKeyExists
}
- return rawdb.WriteCoreDKGPrivateKey(d.db, round, &key)
+ if err != coreDb.ErrDKGPrivateKeyDoesNotExist {
+ return err
+ }
+
+ return rawdb.WriteCoreDKGPrivateKey(d.db, round, reset, &key)
}
func (d *DB) PutCompactionChainTipInfo(hash coreCommon.Hash, height uint64) error {