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@dexon.org>2019-04-11 09:02:21 +0800
commitf1ed7d074fe1d574a84c308c6ad878dc2d153654 (patch)
tree25a6fd9088ac34c7f0ffdf8ec4d48b26bf6ae70e /dex
parent675a9441784b14ee4bd996832c4431adc291c5af (diff)
downloaddexon-f1ed7d074fe1d574a84c308c6ad878dc2d153654.tar.gz
dexon-f1ed7d074fe1d574a84c308c6ad878dc2d153654.tar.zst
dexon-f1ed7d074fe1d574a84c308c6ad878dc2d153654.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 {