Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
validator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
validator
Commits
13b45fab
Commit
13b45fab
authored
Jun 14, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
972628b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
interface.go
core/interface.go
+10
-0
merkle_tree.go
tree/merkle_tree.go
+5
-0
No files found.
core/interface.go
View file @
13b45fab
...
...
@@ -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"
)
...
...
tree/merkle_tree.go
View file @
13b45fab
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment