Commit d9256ec7 authored by 贾浩@五瓣科技's avatar 贾浩@五瓣科技

fix build merkle tree

parent 86f1a4d4
......@@ -18,7 +18,7 @@ claim-monitor-server = "http://18.167.203.17:28080"
commit-offset = 3600 # utc + n seconds
quest-host = "43.198.252.255"
quest-host = "18.167.203.17"
quest-port = 8812
......@@ -26,4 +26,4 @@ quest-user = "admin"
quest-pass = "quest"
quest-db = "qdb"
\ No newline at end of file
quest-db = "qdb"
......@@ -32,6 +32,7 @@ func NewStateDB(lvdb ethdb.KeyValueStore, root common.Hash) (statedb *StateDB, e
func (s *StateDB) GetMinerObject(miner common.Address) (object *validatorv1.MinerObject) {
object = &validatorv1.MinerObject{
Miner: miner.Hex(),
Balance: "0",
}
k := crypto.Keccak256(miner.Bytes())
......
......@@ -163,7 +163,10 @@ func (v *Validator) LoadMerkleTree(date string) (ok bool) {
v.Lock()
v.mtTreeCache[date] = mTree
v.Unlock()
log.WithFields(log.Fields{"date": date, "root": mTree.GetRoot().Hex()}).Debug("load merkle tree")
log.WithFields(log.Fields{
"date": date,
"root": mTree.GetRoot().Hex(),
}).Debug("load merkle tree")
return true
}
......
......@@ -253,7 +253,10 @@ func (v *Validator) Commit() (dayProofs map[common.Address]*validatorv1.Validate
if err != nil {
return
}
log.WithFields(log.Fields{"root": root.Hex(), "cost": time.Since(st).String()}).Info("commit state root")
log.WithFields(log.Fields{
"root": root.Hex(),
"cost": time.Since(st).String(),
}).Info("commit state root")
err = v.lvdb.Put([]byte(fmt.Sprintf("sroot:%s", v.date)), root.Bytes())
if err != nil {
log.WithError(err).Error("failed to update state root")
......
......@@ -14,6 +14,8 @@ merkle sum tree:
mstv:2020-01-01 -> val1:val2
key = keccak(append(big(workload).Bytes(), address.Bytes())),
merkle tree:
......@@ -21,6 +23,8 @@ merkle tree:
mtk:2020-01-01 -> key1(bytes32)key2(bytes32)
key = keccak(append(common.HexToAddress(Miner).Bytes(), common.LeftPadBytes(balance, 32)...))
state:
lastday -> 2023-01-01
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment