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

debug

parent 972628b1
......@@ -65,6 +65,16 @@ func (v *Validator) GetMerkleProof(address common.Address, date string) (balance
bigBalance, _ := new(big.Int).SetString(object.Balance, 10)
payload := append(common.HexToAddress(object.Miner).Bytes(), common.LeftPadBytes(bigBalance.Bytes(), 32)...)
leaf := crypto.Keccak256Hash(payload)
log.WithFields(log.Fields{
"date": date,
"root": cacheTree.GetRoot().Hex(),
}).Debug("cacheTree.GetProof(leaf)")
// 遍历tree
for i, layer := range cacheTree.Layers() {
log.WithField("depth", i).Debug(layer)
}
proofs, err := cacheTree.GetProof(leaf)
if err != nil {
log.WithError(err).Error("failed to get merkle proof")
......
......@@ -64,6 +64,11 @@ func (m *MerkleTree) GetRoot() common.Hash {
return m.layers[len(m.layers)-1][0]
}
func (m *MerkleTree) Layers() [][]common.Hash {
// 临时
return m.layers
}
func (m *MerkleTree) GetProof(el common.Hash) ([]common.Hash, error) {
idx, ok := m.bufferElementPositionIndex[el]
if !ok {
......
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