Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
48dd601d
Commit
48dd601d
authored
Mar 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prep template for fixed size hashes
parent
0a1eeca4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
2 deletions
+50
-2
types_template.go
common/types_template.go
+48
-0
chain_manager.go
core/chain_manager.go
+2
-2
No files found.
common/types_template.go
0 → 100644
View file @
48dd601d
// +build none
//sed -e 's/_N_/Hash/g' -e 's/_S_/32/g' -e '1d' types_template.go | gofmt -w hash.go
package
common
import
"math/big"
type
_N_
[
_S_
]
byte
func
BytesTo_N_
(
b
[]
byte
)
_N_
{
var
h
_N_
h
.
SetBytes
(
b
)
return
h
}
func
StringTo_N_
(
s
string
)
_N_
{
return
BytesTo_N_
([]
byte
(
s
))
}
func
BigTo_N_
(
b
*
big
.
Int
)
_N_
{
return
BytesTo_N_
(
b
.
Bytes
())
}
func
HexTo_N_
(
s
string
)
_N_
{
return
BytesTo_N_
(
FromHex
(
s
))
}
// Don't use the default 'String' method in case we want to overwrite
// Get the string representation of the underlying hash
func
(
h
_N_
)
Str
()
string
{
return
string
(
h
[
:
])
}
func
(
h
_N_
)
Bytes
()
[]
byte
{
return
h
[
:
]
}
func
(
h
_N_
)
Big
()
*
big
.
Int
{
return
Bytes2Big
(
h
[
:
])
}
func
(
h
_N_
)
Hex
()
string
{
return
"0x"
+
Bytes2Hex
(
h
[
:
])
}
// Sets the hash to the value of b. If b is larger than len(h) it will panic
func
(
h
*
_N_
)
SetBytes
(
b
[]
byte
)
{
// Use the right most bytes
if
len
(
b
)
>
len
(
h
)
{
b
=
b
[
len
(
b
)
-
_S_
:
]
}
// Reverse the loop
for
i
:=
len
(
b
)
-
1
;
i
>=
0
;
i
--
{
h
[
_S_
-
len
(
b
)
+
i
]
=
b
[
i
]
}
}
// Set string `s` to h. If s is larger than len(h) it will panic
func
(
h
*
_N_
)
SetString
(
s
string
)
{
h
.
SetBytes
([]
byte
(
s
))
}
// Sets h to other
func
(
h
*
_N_
)
Set
(
other
_N_
)
{
for
i
,
v
:=
range
other
{
h
[
i
]
=
v
}
}
core/chain_manager.go
View file @
48dd601d
...
@@ -37,8 +37,8 @@ func CalcDifficulty(block, parent *types.Header) *big.Int {
...
@@ -37,8 +37,8 @@ func CalcDifficulty(block, parent *types.Header) *big.Int {
diff
.
Sub
(
parent
.
Difficulty
,
adjust
)
diff
.
Sub
(
parent
.
Difficulty
,
adjust
)
}
}
if
diff
.
Cmp
(
GenesisDiff
)
<
0
{
if
diff
.
Cmp
(
min
)
<
0
{
return
GenesisDiff
return
min
}
}
return
diff
return
diff
...
...
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