aboutsummaryrefslogtreecommitdiffstats
path: root/state/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'state/log.go')
-rw-r--r--state/log.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/state/log.go b/state/log.go
index 73039d7ce..49da30535 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
@@ -8,8 +13,8 @@ type Log struct {
Data []byte
}
-func NewLogFromValue(decoder *ethutil.Value) Log {
- log := Log{
+func NewLogFromValue(decoder *ethutil.Value) *Log {
+ log := &Log{
Address: decoder.Get(0).Bytes(),
Data: decoder.Get(2).Bytes(),
}
@@ -22,11 +27,15 @@ func NewLogFromValue(decoder *ethutil.Value) Log {
return log
}
-func (self Log) RlpData() interface{} {
+func (self *Log) RlpData() interface{} {
return []interface{}{self.Address, ethutil.ByteSliceToInterface(self.Topics), self.Data}
}
-type Logs []Log
+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{} {
data := make([]interface{}, len(self))
@@ -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, ", ") + " ]"
+}