good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b26f5e0b
"git@gfx.cafe:elee/erigon.git" did not exist on "13b29abcce0044cc639577d15b9701e40f4bf7d3"
Commit
b26f5e0b
authored
May 31, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
types: block json unmarshal method added
parent
fa4aefee
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/big.go
+4
-4
4 additions, 4 deletions
common/big.go
core/genesis.go
+2
-2
2 additions, 2 deletions
core/genesis.go
core/types/block.go
+24
-0
24 additions, 0 deletions
core/types/block.go
with
30 additions
and
6 deletions
common/big.go
+
4
−
4
View file @
b26f5e0b
...
...
@@ -36,16 +36,16 @@ func Big(num string) *big.Int {
return
n
}
// Big
D
//
Bytes2
Big
//
// Shortcut for new(big.Int).SetBytes(...)
func
Bytes2Big
(
data
[]
byte
)
*
big
.
Int
{
func
BytesToBig
(
data
[]
byte
)
*
big
.
Int
{
n
:=
new
(
big
.
Int
)
n
.
SetBytes
(
data
)
return
n
}
func
BigD
(
data
[]
byte
)
*
big
.
Int
{
return
Bytes2Big
(
data
)
}
func
Bytes2Big
(
data
[]
byte
)
*
big
.
Int
{
return
BytesToBig
(
data
)
}
func
BigD
(
data
[]
byte
)
*
big
.
Int
{
return
BytesToBig
(
data
)
}
func
String2Big
(
num
string
)
*
big
.
Int
{
n
:=
new
(
big
.
Int
)
...
...
This diff is collapsed.
Click to expand it.
core/genesis.go
+
2
−
2
View file @
b26f5e0b
...
...
@@ -36,7 +36,7 @@ func GenesisBlock(db common.Database) *types.Block {
Balance
string
Code
string
}
err
:=
json
.
Unmarshal
(
Genesis
Data
,
&
accounts
)
err
:=
json
.
Unmarshal
(
Genesis
Accounts
,
&
accounts
)
if
err
!=
nil
{
fmt
.
Println
(
"enable to decode genesis json data:"
,
err
)
os
.
Exit
(
1
)
...
...
@@ -57,7 +57,7 @@ func GenesisBlock(db common.Database) *types.Block {
return
genesis
}
var
Genesis
Data
=
[]
byte
(
`{
var
Genesis
Accounts
=
[]
byte
(
`{
"0000000000000000000000000000000000000001": {"balance": "1"},
"0000000000000000000000000000000000000002": {"balance": "1"},
"0000000000000000000000000000000000000003": {"balance": "1"},
...
...
This diff is collapsed.
Click to expand it.
core/types/block.go
+
24
−
0
View file @
b26f5e0b
package
types
import
(
"bytes"
"encoding/binary"
"encoding/json"
"fmt"
"io"
"math/big"
...
...
@@ -80,6 +82,28 @@ func (self *Header) RlpData() interface{} {
return
self
.
rlpData
(
true
)
}
func
(
h
*
Header
)
UnmarshalJSON
(
data
[]
byte
)
error
{
var
ext
struct
{
ParentHash
string
Coinbase
string
Difficulty
string
GasLimit
string
Time
uint64
Extra
string
}
dec
:=
json
.
NewDecoder
(
bytes
.
NewReader
(
data
))
if
err
:=
dec
.
Decode
(
&
ext
);
err
!=
nil
{
return
err
}
h
.
ParentHash
=
common
.
HexToHash
(
ext
.
ParentHash
)
h
.
Coinbase
=
common
.
HexToAddress
(
ext
.
Coinbase
)
h
.
Difficulty
=
common
.
String2Big
(
ext
.
Difficulty
)
h
.
Time
=
ext
.
Time
h
.
Extra
=
[]
byte
(
ext
.
Extra
)
return
nil
}
func
rlpHash
(
x
interface
{})
(
h
common
.
Hash
)
{
hw
:=
sha3
.
NewKeccak256
()
rlp
.
Encode
(
hw
,
x
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment