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
85793a47
Commit
85793a47
authored
May 20, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/4'
parents
6ef28320
3c35ba7c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
11 deletions
+20
-11
state.go
ethchain/state.go
+3
-7
state_object.go
ethchain/state_object.go
+1
-0
vm.go
ethchain/vm.go
+3
-3
pub.go
ethpub/pub.go
+1
-1
trie.go
ethutil/trie.go
+12
-0
No files found.
ethchain/state.go
View file @
85793a47
...
@@ -60,6 +60,7 @@ func (s *State) GetStateObject(addr []byte) *StateObject {
...
@@ -60,6 +60,7 @@ func (s *State) GetStateObject(addr []byte) *StateObject {
// Check if there's a cached state for this contract
// Check if there's a cached state for this contract
cachedStateObject
:=
s
.
states
[
string
(
addr
)]
cachedStateObject
:=
s
.
states
[
string
(
addr
)]
if
cachedStateObject
!=
nil
{
if
cachedStateObject
!=
nil
{
//fmt.Printf("get cached #%d %x addr: %x\n", cachedStateObject.trie.Cache().Len(), cachedStateObject.Root(), addr[0:4])
stateObject
.
state
=
cachedStateObject
stateObject
.
state
=
cachedStateObject
}
}
...
@@ -70,8 +71,9 @@ func (s *State) GetStateObject(addr []byte) *StateObject {
...
@@ -70,8 +71,9 @@ func (s *State) GetStateObject(addr []byte) *StateObject {
func
(
s
*
State
)
UpdateStateObject
(
object
*
StateObject
)
{
func
(
s
*
State
)
UpdateStateObject
(
object
*
StateObject
)
{
addr
:=
object
.
Address
()
addr
:=
object
.
Address
()
if
object
.
state
!=
nil
{
if
object
.
state
!=
nil
&&
s
.
states
[
string
(
addr
)]
==
nil
{
s
.
states
[
string
(
addr
)]
=
object
.
state
s
.
states
[
string
(
addr
)]
=
object
.
state
//fmt.Printf("update cached #%d %x addr: %x\n", object.state.trie.Cache().Len(), object.state.Root(), addr[0:4])
}
}
ethutil
.
Config
.
Db
.
Put
(
ethutil
.
Sha3Bin
(
object
.
Script
()),
object
.
Script
())
ethutil
.
Config
.
Db
.
Put
(
ethutil
.
Sha3Bin
(
object
.
Script
()),
object
.
Script
())
...
@@ -81,12 +83,6 @@ func (s *State) UpdateStateObject(object *StateObject) {
...
@@ -81,12 +83,6 @@ func (s *State) UpdateStateObject(object *StateObject) {
s
.
manifest
.
AddObjectChange
(
object
)
s
.
manifest
.
AddObjectChange
(
object
)
}
}
func
(
s
*
State
)
SetStateObject
(
stateObject
*
StateObject
)
{
s
.
states
[
string
(
stateObject
.
address
)]
=
stateObject
.
state
s
.
UpdateStateObject
(
stateObject
)
}
func
(
s
*
State
)
GetAccount
(
addr
[]
byte
)
(
account
*
StateObject
)
{
func
(
s
*
State
)
GetAccount
(
addr
[]
byte
)
(
account
*
StateObject
)
{
data
:=
s
.
trie
.
Get
(
string
(
addr
))
data
:=
s
.
trie
.
Get
(
string
(
addr
))
if
data
==
""
{
if
data
==
""
{
...
...
ethchain/state_object.go
View file @
85793a47
...
@@ -78,6 +78,7 @@ func (c *StateObject) SetAddr(addr []byte, value interface{}) {
...
@@ -78,6 +78,7 @@ func (c *StateObject) SetAddr(addr []byte, value interface{}) {
func
(
c
*
StateObject
)
SetStorage
(
num
*
big
.
Int
,
val
*
ethutil
.
Value
)
{
func
(
c
*
StateObject
)
SetStorage
(
num
*
big
.
Int
,
val
*
ethutil
.
Value
)
{
addr
:=
ethutil
.
BigToBytes
(
num
,
256
)
addr
:=
ethutil
.
BigToBytes
(
num
,
256
)
//fmt.Println("storing", val.BigInt(), "@", num)
c
.
SetAddr
(
addr
,
val
)
c
.
SetAddr
(
addr
,
val
)
}
}
...
...
ethchain/vm.go
View file @
85793a47
...
@@ -448,7 +448,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -448,7 +448,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
}
else
{
}
else
{
stack
.
Push
(
ethutil
.
BigD
(
addr
))
stack
.
Push
(
ethutil
.
BigD
(
addr
))
vm
.
state
.
Set
StateObject
(
contract
)
vm
.
state
.
Update
StateObject
(
contract
)
}
}
case
oCALL
:
case
oCALL
:
require
(
7
)
require
(
7
)
...
@@ -497,7 +497,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -497,7 +497,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
stack
.
Push
(
ethutil
.
BigTrue
)
stack
.
Push
(
ethutil
.
BigTrue
)
}
}
vm
.
state
.
Set
StateObject
(
contract
)
vm
.
state
.
Update
StateObject
(
contract
)
mem
.
Set
(
retOffset
.
Int64
(),
retSize
.
Int64
(),
ret
)
mem
.
Set
(
retOffset
.
Int64
(),
retSize
.
Int64
(),
ret
)
}
else
{
}
else
{
...
@@ -515,7 +515,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -515,7 +515,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
receiver
:=
vm
.
state
.
GetAccount
(
stack
.
Pop
()
.
Bytes
())
receiver
:=
vm
.
state
.
GetAccount
(
stack
.
Pop
()
.
Bytes
())
receiver
.
AddAmount
(
closure
.
object
.
Amount
)
receiver
.
AddAmount
(
closure
.
object
.
Amount
)
vm
.
state
.
Set
StateObject
(
receiver
)
vm
.
state
.
Update
StateObject
(
receiver
)
closure
.
object
.
state
.
Purge
()
closure
.
object
.
state
.
Purge
()
...
...
ethpub/pub.go
View file @
85793a47
...
@@ -162,7 +162,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
...
@@ -162,7 +162,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
acc
:=
lib
.
stateManager
.
TransState
()
.
GetStateObject
(
keyPair
.
Address
())
acc
:=
lib
.
stateManager
.
TransState
()
.
GetStateObject
(
keyPair
.
Address
())
tx
.
Nonce
=
acc
.
Nonce
tx
.
Nonce
=
acc
.
Nonce
acc
.
Nonce
+=
1
acc
.
Nonce
+=
1
lib
.
stateManager
.
TransState
()
.
Set
StateObject
(
acc
)
lib
.
stateManager
.
TransState
()
.
Update
StateObject
(
acc
)
tx
.
Sign
(
keyPair
.
PrivateKey
)
tx
.
Sign
(
keyPair
.
PrivateKey
)
lib
.
txPool
.
QueueTransaction
(
tx
)
lib
.
txPool
.
QueueTransaction
(
tx
)
...
...
ethutil/trie.go
View file @
85793a47
...
@@ -3,8 +3,13 @@ package ethutil
...
@@ -3,8 +3,13 @@ package ethutil
import
(
import
(
"fmt"
"fmt"
"reflect"
"reflect"
"sync"
)
)
func
(
s
*
Cache
)
Len
()
int
{
return
len
(
s
.
nodes
)
}
// TODO
// TODO
// A StateObject is an object that has a state root
// A StateObject is an object that has a state root
// This is goig to be the object for the second level caching (the caching of object which have a state such as contracts)
// This is goig to be the object for the second level caching (the caching of object which have a state such as contracts)
...
@@ -113,6 +118,7 @@ func (cache *Cache) Undo() {
...
@@ -113,6 +118,7 @@ func (cache *Cache) Undo() {
// Please note that the data isn't persisted unless `Sync` is
// Please note that the data isn't persisted unless `Sync` is
// explicitly called.
// explicitly called.
type
Trie
struct
{
type
Trie
struct
{
mut
sync
.
RWMutex
prevRoot
interface
{}
prevRoot
interface
{}
Root
interface
{}
Root
interface
{}
//db Database
//db Database
...
@@ -157,12 +163,18 @@ func (t *Trie) Cache() *Cache {
...
@@ -157,12 +163,18 @@ func (t *Trie) Cache() *Cache {
* Public (query) interface functions
* Public (query) interface functions
*/
*/
func
(
t
*
Trie
)
Update
(
key
string
,
value
string
)
{
func
(
t
*
Trie
)
Update
(
key
string
,
value
string
)
{
t
.
mut
.
Lock
()
defer
t
.
mut
.
Unlock
()
k
:=
CompactHexDecode
(
key
)
k
:=
CompactHexDecode
(
key
)
t
.
Root
=
t
.
UpdateState
(
t
.
Root
,
k
,
value
)
t
.
Root
=
t
.
UpdateState
(
t
.
Root
,
k
,
value
)
}
}
func
(
t
*
Trie
)
Get
(
key
string
)
string
{
func
(
t
*
Trie
)
Get
(
key
string
)
string
{
t
.
mut
.
RLock
()
defer
t
.
mut
.
RUnlock
()
k
:=
CompactHexDecode
(
key
)
k
:=
CompactHexDecode
(
key
)
c
:=
NewValue
(
t
.
GetState
(
t
.
Root
,
k
))
c
:=
NewValue
(
t
.
GetState
(
t
.
Root
,
k
))
...
...
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