forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum#52 from maticnetwork/dev-roothash
new: Add bor.getRootHash(start, end) api method (MAT-1302)
- Loading branch information
Showing
12 changed files
with
199 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package bor | ||
|
||
func appendBytes32(data ...[]byte) []byte { | ||
var result []byte | ||
for _, v := range data { | ||
paddedV, err := convertTo32(v) | ||
if err == nil { | ||
result = append(result, paddedV[:]...) | ||
} | ||
} | ||
return result | ||
} | ||
|
||
func nextPowerOfTwo(n uint64) uint64 { | ||
if n == 0 { | ||
return 1 | ||
} | ||
// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | ||
n-- | ||
n |= n >> 1 | ||
n |= n >> 2 | ||
n |= n >> 4 | ||
n |= n >> 8 | ||
n |= n >> 16 | ||
n |= n >> 32 | ||
n++ | ||
return n | ||
} | ||
|
||
func convertTo32(input []byte) (output [32]byte, err error) { | ||
l := len(input) | ||
if l > 32 || l == 0 { | ||
return | ||
} | ||
copy(output[32-l:], input[:]) | ||
return | ||
} | ||
|
||
func convert(input []([32]byte)) [][]byte { | ||
var output [][]byte | ||
for _, in := range input { | ||
newInput := make([]byte, len(in[:])) | ||
copy(newInput, in[:]) | ||
output = append(output, newInput) | ||
|
||
} | ||
return output | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters