aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-22 20:24:26 +0800
committerobscuren <geffobscura@gmail.com>2015-02-22 20:24:26 +0800
commitbba85a207488d27819dc6f6f5758b80947ea200b (patch)
tree46ab6ed3f414d008019d8c35d90cf16ed0ef4dfd
parent483d96a89d68023360d211ab329400f4b960fe48 (diff)
downloaddexon-bba85a207488d27819dc6f6f5758b80947ea200b.tar.gz
dexon-bba85a207488d27819dc6f6f5758b80947ea200b.tar.zst
dexon-bba85a207488d27819dc6f6f5758b80947ea200b.zip
Added Number to logs
-rw-r--r--rpc/util.go2
-rw-r--r--state/log.go11
-rw-r--r--vm/environment.go5
-rw-r--r--vm/vm.go2
4 files changed, 17 insertions, 3 deletions
diff --git a/rpc/util.go b/rpc/util.go
index 29824bcdb..1939b3474 100644
--- a/rpc/util.go
+++ b/rpc/util.go
@@ -84,6 +84,7 @@ type Log struct {
Address string `json:"address"`
Topic []string `json:"topics"`
Data string `json:"data"`
+ Number uint64 `json:"number"`
}
func toLogs(logs state.Logs) (ls []Log) {
@@ -94,6 +95,7 @@ func toLogs(logs state.Logs) (ls []Log) {
l.Topic = make([]string, len(log.Topics()))
l.Address = toHex(log.Address())
l.Data = toHex(log.Data())
+ l.Number = log.Number()
for j, topic := range log.Topics() {
l.Topic[j] = toHex(topic)
}
diff --git a/state/log.go b/state/log.go
index 46360f4aa..d503bd1a0 100644
--- a/state/log.go
+++ b/state/log.go
@@ -12,16 +12,19 @@ type Log interface {
Address() []byte
Topics() [][]byte
Data() []byte
+
+ Number() uint64
}
type StateLog struct {
address []byte
topics [][]byte
data []byte
+ number uint64
}
-func NewLog(address []byte, topics [][]byte, data []byte) *StateLog {
- return &StateLog{address, topics, data}
+func NewLog(address []byte, topics [][]byte, data []byte, number uint64) *StateLog {
+ return &StateLog{address, topics, data, number}
}
func (self *StateLog) Address() []byte {
@@ -36,6 +39,10 @@ func (self *StateLog) Data() []byte {
return self.data
}
+func (self *StateLog) Number() uint64 {
+ return self.number
+}
+
func NewLogFromValue(decoder *ethutil.Value) *StateLog {
log := &StateLog{
address: decoder.Get(0).Bytes(),
diff --git a/vm/environment.go b/vm/environment.go
index 8507e248f..5b4d6c8f0 100644
--- a/vm/environment.go
+++ b/vm/environment.go
@@ -54,6 +54,7 @@ type Log struct {
address []byte
topics [][]byte
data []byte
+ log uint64
}
func (self *Log) Address() []byte {
@@ -68,6 +69,10 @@ func (self *Log) Data() []byte {
return self.data
}
+func (self *Log) Number() uint64 {
+ return self.log
+}
+
func (self *Log) RlpData() interface{} {
return []interface{}{self.address, ethutil.ByteSliceToInterface(self.topics), self.data}
}
diff --git a/vm/vm.go b/vm/vm.go
index 5ec507ddc..b20d7b603 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -578,7 +578,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
}
data := mem.Get(mStart.Int64(), mSize.Int64())
- log := &Log{context.Address(), topics, data}
+ log := &Log{context.Address(), topics, data, self.env.BlockNumber().Uint64()}
self.env.AddLog(log)
self.Printf(" => %v", log)