From 75ee3b3f089e703b728bb301cc6b2abe4c111c41 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 11 Nov 2014 12:16:36 +0100 Subject: debugging code --- state/log.go | 19 ++++++++++++++++++- state/state.go | 6 +++--- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'state') diff --git a/state/log.go b/state/log.go index 73039d7ce..e61a4186e 100644 --- a/state/log.go +++ b/state/log.go @@ -1,6 +1,11 @@ package state -import "github.com/ethereum/go-ethereum/ethutil" +import ( + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/ethutil" +) type Log struct { Address []byte @@ -26,6 +31,10 @@ func (self Log) RlpData() interface{} { return []interface{}{self.Address, ethutil.ByteSliceToInterface(self.Topics), self.Data} } +func (self Log) String() string { + return fmt.Sprintf(`log: %x %x %x`, self.Address, self.Topics, self.Data) +} + type Logs []Log func (self Logs) RlpData() interface{} { @@ -36,3 +45,11 @@ func (self Logs) RlpData() interface{} { return data } + +func (self Logs) String() string { + var logs []string + for _, log := range self { + logs = append(logs, log.String()) + } + return "[ " + strings.Join(logs, ", ") + " ]" +} diff --git a/state/state.go b/state/state.go index e1b73a6ab..8eb348dda 100644 --- a/state/state.go +++ b/state/state.go @@ -62,7 +62,7 @@ func (self *State) Refund(addr []byte, gas, price *big.Int) { self.refund[string(addr)] = new(big.Int) } - self.refund[string(addr)] = new(big.Int).Add(self.refund[string(addr)], amount) + self.refund[string(addr)].Add(self.refund[string(addr)], amount) } func (self *State) AddBalance(addr []byte, amount *big.Int) { @@ -237,8 +237,8 @@ func (self *State) Set(state *State) { self.logs = state.logs } -func (s *State) Root() interface{} { - return s.Trie.Root +func (s *State) Root() []byte { + return s.Trie.GetRoot() } // Resets the trie and all siblings -- cgit v1.2.3