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
5a0c4ce2
Commit
5a0c4ce2
authored
Jul 13, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Fixed "Copy" to also copy over the pending storage changes
parent
04f8c455
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ethchain/state_object.go
+18
-5
18 additions, 5 deletions
ethchain/state_object.go
with
18 additions
and
5 deletions
ethchain/state_object.go
+
18
−
5
View file @
5a0c4ce2
...
@@ -15,6 +15,18 @@ func (self Code) String() string {
...
@@ -15,6 +15,18 @@ func (self Code) String() string {
return
strings
.
Join
(
Disassemble
(
self
),
" "
)
return
strings
.
Join
(
Disassemble
(
self
),
" "
)
}
}
type
Storage
map
[
string
]
*
ethutil
.
Value
func
(
self
Storage
)
Copy
()
Storage
{
cpy
:=
make
(
Storage
)
for
key
,
value
:=
range
self
{
// XXX Do we need a 'value' copy or is this sufficient?
cpy
[
key
]
=
value
}
return
cpy
}
type
StateObject
struct
{
type
StateObject
struct
{
// Address of the object
// Address of the object
address
[]
byte
address
[]
byte
...
@@ -27,7 +39,7 @@ type StateObject struct {
...
@@ -27,7 +39,7 @@ type StateObject struct {
script
Code
script
Code
initScript
Code
initScript
Code
storage
map
[
string
]
*
ethutil
.
Valu
e
storage
Storag
e
// Total gas pool is the total amount of gas currently
// Total gas pool is the total amount of gas currently
// left if this object is the coinbase. Gas is directly
// left if this object is the coinbase. Gas is directly
...
@@ -41,7 +53,7 @@ type StateObject struct {
...
@@ -41,7 +53,7 @@ type StateObject struct {
}
}
func
(
self
*
StateObject
)
Reset
()
{
func
(
self
*
StateObject
)
Reset
()
{
self
.
storage
=
make
(
map
[
string
]
*
ethutil
.
Valu
e
)
self
.
storage
=
make
(
Storag
e
)
}
}
// Converts an transaction in to a state object
// Converts an transaction in to a state object
...
@@ -95,7 +107,7 @@ func NewStateObjectFromBytes(address, data []byte) *StateObject {
...
@@ -95,7 +107,7 @@ func NewStateObjectFromBytes(address, data []byte) *StateObject {
func
(
self
*
StateObject
)
MarkForDeletion
()
{
func
(
self
*
StateObject
)
MarkForDeletion
()
{
self
.
remove
=
true
self
.
remove
=
true
statelogger
.
Info
f
(
"%x: #%d %v (deletion)
\n
"
,
self
.
Address
(),
self
.
Nonce
,
self
.
Amount
)
statelogger
.
DebugDetail
f
(
"%x: #%d %v (deletion)
\n
"
,
self
.
Address
(),
self
.
Nonce
,
self
.
Amount
)
}
}
func
(
c
*
StateObject
)
GetAddr
(
addr
[]
byte
)
*
ethutil
.
Value
{
func
(
c
*
StateObject
)
GetAddr
(
addr
[]
byte
)
*
ethutil
.
Value
{
...
@@ -154,13 +166,13 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
...
@@ -154,13 +166,13 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
func
(
c
*
StateObject
)
AddAmount
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
AddAmount
(
amount
*
big
.
Int
)
{
c
.
SetAmount
(
new
(
big
.
Int
)
.
Add
(
c
.
Amount
,
amount
))
c
.
SetAmount
(
new
(
big
.
Int
)
.
Add
(
c
.
Amount
,
amount
))
statelogger
.
Info
f
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
Nonce
,
c
.
Amount
,
amount
)
statelogger
.
DebugDetail
f
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
Nonce
,
c
.
Amount
,
amount
)
}
}
func
(
c
*
StateObject
)
SubAmount
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
SubAmount
(
amount
*
big
.
Int
)
{
c
.
SetAmount
(
new
(
big
.
Int
)
.
Sub
(
c
.
Amount
,
amount
))
c
.
SetAmount
(
new
(
big
.
Int
)
.
Sub
(
c
.
Amount
,
amount
))
statelogger
.
Info
f
(
"%x: #%d %v (- %v)
\n
"
,
c
.
Address
(),
c
.
Nonce
,
c
.
Amount
,
amount
)
statelogger
.
DebugDetail
f
(
"%x: #%d %v (- %v)
\n
"
,
c
.
Address
(),
c
.
Nonce
,
c
.
Amount
,
amount
)
}
}
func
(
c
*
StateObject
)
SetAmount
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
SetAmount
(
amount
*
big
.
Int
)
{
...
@@ -222,6 +234,7 @@ func (self *StateObject) Copy() *StateObject {
...
@@ -222,6 +234,7 @@ func (self *StateObject) Copy() *StateObject {
}
}
stateObject
.
script
=
ethutil
.
CopyBytes
(
self
.
script
)
stateObject
.
script
=
ethutil
.
CopyBytes
(
self
.
script
)
stateObject
.
initScript
=
ethutil
.
CopyBytes
(
self
.
initScript
)
stateObject
.
initScript
=
ethutil
.
CopyBytes
(
self
.
initScript
)
stateObject
.
storage
=
self
.
storage
.
Copy
()
return
stateObject
return
stateObject
}
}
...
...
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