aboutsummaryrefslogtreecommitdiffstats
path: root/core/rawdb
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-21 08:37:33 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:58 +0800
commit9ad0e05b15f8b36f38f19cc1b24dc8b93e845844 (patch)
tree8dd2847c1003a1de9757990ebb53a8322cba333b /core/rawdb
parent86eb10fc5f853507baafde992b81647d41f2a587 (diff)
downloaddexon-9ad0e05b15f8b36f38f19cc1b24dc8b93e845844.tar.gz
dexon-9ad0e05b15f8b36f38f19cc1b24dc8b93e845844.tar.zst
dexon-9ad0e05b15f8b36f38f19cc1b24dc8b93e845844.zip
core/vm: remove round from addDKG functions (#279)
* vendor: sync to latest core * core/vm: remove addDKG functions * core: fix conflict
Diffstat (limited to 'core/rawdb')
-rw-r--r--core/rawdb/accessors_core_dkg_master_private_shares.go44
-rw-r--r--core/rawdb/accessors_core_dkg_protocol.go44
-rw-r--r--core/rawdb/schema.go16
3 files changed, 48 insertions, 56 deletions
diff --git a/core/rawdb/accessors_core_dkg_master_private_shares.go b/core/rawdb/accessors_core_dkg_master_private_shares.go
deleted file mode 100644
index 23b37f361..000000000
--- a/core/rawdb/accessors_core_dkg_master_private_shares.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package rawdb
-
-import (
- "bytes"
-
- coreDKG "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg"
- "github.com/dexon-foundation/dexon/log"
- "github.com/dexon-foundation/dexon/rlp"
-)
-
-func ReadCoreDKGMasterPrivateSharesRLP(db DatabaseReader, round uint64) rlp.RawValue {
- data, _ := db.Get(coreDKGMasterPrivateSharesKey(round))
- return data
-}
-
-func WriteCoreDKGMasterPrivateSharesRLP(db DatabaseWriter, round uint64, rlp rlp.RawValue) error {
- err := db.Put(coreDKGMasterPrivateSharesKey(round), rlp)
- if err != nil {
- log.Crit("Failed to store core DKG private key", "err", err, "round", round)
- }
- return err
-}
-
-func ReadCoreDKGMasterPrivateShares(db DatabaseReader, round uint64) *coreDKG.PrivateKeyShares {
- data := ReadCoreDKGMasterPrivateSharesRLP(db, round)
- if len(data) == 0 {
- return nil
- }
- shares := new(coreDKG.PrivateKeyShares)
- if err := rlp.Decode(bytes.NewReader(data), shares); err != nil {
- log.Error("Invalid core DKG master private shares RLP", "round", round, "err", err)
- return nil
- }
- return shares
-}
-
-func WriteCoreDKGMasterPrivateShares(db DatabaseWriter, round uint64, shares *coreDKG.PrivateKeyShares) error {
- data, err := rlp.EncodeToBytes(shares)
- if err != nil {
- log.Crit("Failed to RLP encode core DKG master private shares", "round", round, "err", err)
- return err
- }
- return WriteCoreDKGMasterPrivateSharesRLP(db, round, data)
-}
diff --git a/core/rawdb/accessors_core_dkg_protocol.go b/core/rawdb/accessors_core_dkg_protocol.go
new file mode 100644
index 000000000..ba087b00d
--- /dev/null
+++ b/core/rawdb/accessors_core_dkg_protocol.go
@@ -0,0 +1,44 @@
+package rawdb
+
+import (
+ "bytes"
+
+ coreDb "github.com/dexon-foundation/dexon-consensus/core/db"
+ "github.com/dexon-foundation/dexon/log"
+ "github.com/dexon-foundation/dexon/rlp"
+)
+
+func ReadCoreDKGProtocolRLP(db DatabaseReader) rlp.RawValue {
+ data, _ := db.Get(coreDKGProtocolKey)
+ return data
+}
+
+func WriteCoreDKGProtocolRLP(db DatabaseWriter, rlp rlp.RawValue) error {
+ err := db.Put(coreDKGProtocolKey, rlp)
+ if err != nil {
+ log.Crit("Failed to store core DKG private key", "err", err)
+ }
+ return err
+}
+
+func ReadCoreDKGProtocol(db DatabaseReader) *coreDb.DKGProtocolInfo {
+ data := ReadCoreDKGProtocolRLP(db)
+ if len(data) == 0 {
+ return nil
+ }
+ protocol := new(coreDb.DKGProtocolInfo)
+ if err := rlp.Decode(bytes.NewReader(data), protocol); err != nil {
+ log.Error("Invalid core DKG protocol RLP", "err", err)
+ return nil
+ }
+ return protocol
+}
+
+func WriteCoreDKGProtocol(db DatabaseWriter, protocol *coreDb.DKGProtocolInfo) error {
+ data, err := rlp.EncodeToBytes(protocol)
+ if err != nil {
+ log.Crit("Failed to RLP encode core DKG protocol", "err", err)
+ return err
+ }
+ return WriteCoreDKGProtocolRLP(db, data)
+}
diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go
index b469468f4..8ca47676d 100644
--- a/core/rawdb/schema.go
+++ b/core/rawdb/schema.go
@@ -53,10 +53,10 @@ var (
txLookupPrefix = []byte("l") // txLookupPrefix + hash -> transaction/receipt lookup metadata
bloomBitsPrefix = []byte("B") // bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits
- coreBlockPrefix = []byte("D")
- coreDKGPrivateKeyPrefix = []byte("DPK")
- coreCompactionChainTipKey = []byte("CoreChainTip")
- coreDKGMasterPrivateSharesPrefix = []byte("CoreDKGPrv")
+ coreBlockPrefix = []byte("D")
+ coreDKGPrivateKeyPrefix = []byte("DPK")
+ coreCompactionChainTipKey = []byte("CoreChainTip")
+ coreDKGProtocolKey = []byte("CoreDKGProtocol")
preimagePrefix = []byte("secure-key-") // preimagePrefix + hash -> preimage
configPrefix = []byte("ethereum-config-") // config prefix for the db
@@ -131,14 +131,6 @@ func coreDKGPrivateKeyKey(round uint64) []byte {
return ret
}
-// coreDKGMasterPrivateSharesKey = coreDKGMasterPrivateSharesPrefix + round
-func coreDKGMasterPrivateSharesKey(round uint64) []byte {
- ret := make([]byte, len(coreDKGMasterPrivateSharesPrefix)+8)
- copy(ret, coreDKGMasterPrivateSharesPrefix)
- binary.LittleEndian.PutUint64(ret[len(coreDKGMasterPrivateSharesPrefix):], round)
- return ret
-}
-
// bloomBitsKey = bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash
func bloomBitsKey(bit uint, section uint64, hash common.Hash) []byte {
key := append(append(bloomBitsPrefix, make([]byte, 10)...), hash.Bytes()...)