good morning!!!!

Skip to content
Snippets Groups Projects
Commit 5a0c4ce2 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

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
...@@ -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.Value storage Storage
// 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.Value) self.storage = make(Storage)
} }
// 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.Infof("%x: #%d %v (deletion)\n", self.Address(), self.Nonce, self.Amount) statelogger.DebugDetailf("%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.Infof("%x: #%d %v (+ %v)\n", c.Address(), c.Nonce, c.Amount, amount) statelogger.DebugDetailf("%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.Infof("%x: #%d %v (- %v)\n", c.Address(), c.Nonce, c.Amount, amount) statelogger.DebugDetailf("%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
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment