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
03ce15df
Commit
03ce15df
authored
Aug 04, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethstate.NewState => ethstate.New
parent
3debeb72
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
11 deletions
+12
-11
block.go
ethchain/block.go
+3
-3
state_transition.go
ethchain/state_transition.go
+1
-1
state.go
ethstate/state.go
+2
-2
state_object.go
ethstate/state_object.go
+3
-3
state_test.go
ethstate/state_test.go
+3
-2
No files found.
ethchain/block.go
View file @
03ce15df
...
@@ -100,7 +100,7 @@ func CreateBlock(root interface{},
...
@@ -100,7 +100,7 @@ func CreateBlock(root interface{},
}
}
block
.
SetUncles
([]
*
Block
{})
block
.
SetUncles
([]
*
Block
{})
block
.
state
=
ethstate
.
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
root
))
block
.
state
=
ethstate
.
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
root
))
return
block
return
block
}
}
...
@@ -265,7 +265,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) {
...
@@ -265,7 +265,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) {
block
.
PrevHash
=
header
.
Get
(
0
)
.
Bytes
()
block
.
PrevHash
=
header
.
Get
(
0
)
.
Bytes
()
block
.
UncleSha
=
header
.
Get
(
1
)
.
Bytes
()
block
.
UncleSha
=
header
.
Get
(
1
)
.
Bytes
()
block
.
Coinbase
=
header
.
Get
(
2
)
.
Bytes
()
block
.
Coinbase
=
header
.
Get
(
2
)
.
Bytes
()
block
.
state
=
ethstate
.
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
header
.
Get
(
3
)
.
Val
))
block
.
state
=
ethstate
.
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
header
.
Get
(
3
)
.
Val
))
block
.
TxSha
=
header
.
Get
(
4
)
.
Bytes
()
block
.
TxSha
=
header
.
Get
(
4
)
.
Bytes
()
block
.
Difficulty
=
header
.
Get
(
5
)
.
BigInt
()
block
.
Difficulty
=
header
.
Get
(
5
)
.
BigInt
()
block
.
Number
=
header
.
Get
(
6
)
.
BigInt
()
block
.
Number
=
header
.
Get
(
6
)
.
BigInt
()
...
@@ -307,7 +307,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
...
@@ -307,7 +307,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
block
.
PrevHash
=
header
.
Get
(
0
)
.
Bytes
()
block
.
PrevHash
=
header
.
Get
(
0
)
.
Bytes
()
block
.
UncleSha
=
header
.
Get
(
1
)
.
Bytes
()
block
.
UncleSha
=
header
.
Get
(
1
)
.
Bytes
()
block
.
Coinbase
=
header
.
Get
(
2
)
.
Bytes
()
block
.
Coinbase
=
header
.
Get
(
2
)
.
Bytes
()
block
.
state
=
ethstate
.
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
header
.
Get
(
3
)
.
Val
))
block
.
state
=
ethstate
.
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
header
.
Get
(
3
)
.
Val
))
block
.
TxSha
=
header
.
Get
(
4
)
.
Bytes
()
block
.
TxSha
=
header
.
Get
(
4
)
.
Bytes
()
block
.
Difficulty
=
header
.
Get
(
5
)
.
BigInt
()
block
.
Difficulty
=
header
.
Get
(
5
)
.
BigInt
()
block
.
Number
=
header
.
Get
(
6
)
.
BigInt
()
block
.
Number
=
header
.
Get
(
6
)
.
BigInt
()
...
...
ethchain/state_transition.go
View file @
03ce15df
...
@@ -278,7 +278,7 @@ func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject
...
@@ -278,7 +278,7 @@ func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject
contract
:=
state
.
NewStateObject
(
addr
)
contract
:=
state
.
NewStateObject
(
addr
)
contract
.
InitCode
=
tx
.
Data
contract
.
InitCode
=
tx
.
Data
contract
.
State
=
ethstate
.
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
""
))
contract
.
State
=
ethstate
.
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
""
))
return
contract
return
contract
}
}
...
...
ethstate/state.go
View file @
03ce15df
...
@@ -26,7 +26,7 @@ type State struct {
...
@@ -26,7 +26,7 @@ type State struct {
}
}
// Create a new state from a given trie
// Create a new state from a given trie
func
New
State
(
trie
*
ethtrie
.
Trie
)
*
State
{
func
New
(
trie
*
ethtrie
.
Trie
)
*
State
{
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
()}
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
()}
}
}
...
@@ -128,7 +128,7 @@ func (s *State) Cmp(other *State) bool {
...
@@ -128,7 +128,7 @@ func (s *State) Cmp(other *State) bool {
func
(
self
*
State
)
Copy
()
*
State
{
func
(
self
*
State
)
Copy
()
*
State
{
if
self
.
Trie
!=
nil
{
if
self
.
Trie
!=
nil
{
state
:=
New
State
(
self
.
Trie
.
Copy
())
state
:=
New
(
self
.
Trie
.
Copy
())
for
k
,
stateObject
:=
range
self
.
stateObjects
{
for
k
,
stateObject
:=
range
self
.
stateObjects
{
state
.
stateObjects
[
k
]
=
stateObject
.
Copy
()
state
.
stateObjects
[
k
]
=
stateObject
.
Copy
()
}
}
...
...
ethstate/state_object.go
View file @
03ce15df
...
@@ -62,7 +62,7 @@ func NewStateObject(addr []byte) *StateObject {
...
@@ -62,7 +62,7 @@ func NewStateObject(addr []byte) *StateObject {
address
:=
ethutil
.
Address
(
addr
)
address
:=
ethutil
.
Address
(
addr
)
object
:=
&
StateObject
{
address
:
address
,
Balance
:
new
(
big
.
Int
),
gasPool
:
new
(
big
.
Int
)}
object
:=
&
StateObject
{
address
:
address
,
Balance
:
new
(
big
.
Int
),
gasPool
:
new
(
big
.
Int
)}
object
.
State
=
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
""
))
object
.
State
=
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
""
))
object
.
storage
=
make
(
Storage
)
object
.
storage
=
make
(
Storage
)
object
.
gasPool
=
new
(
big
.
Int
)
object
.
gasPool
=
new
(
big
.
Int
)
...
@@ -72,7 +72,7 @@ func NewStateObject(addr []byte) *StateObject {
...
@@ -72,7 +72,7 @@ func NewStateObject(addr []byte) *StateObject {
func
NewContract
(
address
[]
byte
,
balance
*
big
.
Int
,
root
[]
byte
)
*
StateObject
{
func
NewContract
(
address
[]
byte
,
balance
*
big
.
Int
,
root
[]
byte
)
*
StateObject
{
contract
:=
NewStateObject
(
address
)
contract
:=
NewStateObject
(
address
)
contract
.
Balance
=
balance
contract
.
Balance
=
balance
contract
.
State
=
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
string
(
root
)))
contract
.
State
=
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
string
(
root
)))
return
contract
return
contract
}
}
...
@@ -300,7 +300,7 @@ func (c *StateObject) RlpDecode(data []byte) {
...
@@ -300,7 +300,7 @@ func (c *StateObject) RlpDecode(data []byte) {
c
.
Nonce
=
decoder
.
Get
(
0
)
.
Uint
()
c
.
Nonce
=
decoder
.
Get
(
0
)
.
Uint
()
c
.
Balance
=
decoder
.
Get
(
1
)
.
BigInt
()
c
.
Balance
=
decoder
.
Get
(
1
)
.
BigInt
()
c
.
State
=
New
State
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
decoder
.
Get
(
2
)
.
Interface
()))
c
.
State
=
New
(
ethtrie
.
New
(
ethutil
.
Config
.
Db
,
decoder
.
Get
(
2
)
.
Interface
()))
c
.
storage
=
make
(
map
[
string
]
*
ethutil
.
Value
)
c
.
storage
=
make
(
map
[
string
]
*
ethutil
.
Value
)
c
.
gasPool
=
new
(
big
.
Int
)
c
.
gasPool
=
new
(
big
.
Int
)
...
...
ethstate/state_test.go
View file @
03ce15df
package
ethstate
package
ethstate
import
(
import
(
"testing"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethtrie"
"github.com/ethereum/eth-go/ethtrie"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"testing"
)
)
var
ZeroHash256
=
make
([]
byte
,
32
)
var
ZeroHash256
=
make
([]
byte
,
32
)
...
@@ -14,7 +15,7 @@ func TestSnapshot(t *testing.T) {
...
@@ -14,7 +15,7 @@ func TestSnapshot(t *testing.T) {
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
Config
.
Db
=
db
ethutil
.
Config
.
Db
=
db
state
:=
New
State
(
ethtrie
.
NewTrie
(
db
,
""
))
state
:=
New
(
ethtrie
.
New
(
db
,
""
))
stateObject
:=
state
.
GetOrNewStateObject
([]
byte
(
"aa"
))
stateObject
:=
state
.
GetOrNewStateObject
([]
byte
(
"aa"
))
...
...
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