Skip to content

Commit bba85a2

Browse files
committed
Added Number to logs
1 parent 483d96a commit bba85a2

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

rpc/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type Log struct {
8484
Address string `json:"address"`
8585
Topic []string `json:"topics"`
8686
Data string `json:"data"`
87+
Number uint64 `json:"number"`
8788
}
8889

8990
func toLogs(logs state.Logs) (ls []Log) {
@@ -94,6 +95,7 @@ func toLogs(logs state.Logs) (ls []Log) {
9495
l.Topic = make([]string, len(log.Topics()))
9596
l.Address = toHex(log.Address())
9697
l.Data = toHex(log.Data())
98+
l.Number = log.Number()
9799
for j, topic := range log.Topics() {
98100
l.Topic[j] = toHex(topic)
99101
}

state/log.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ type Log interface {
1212
Address() []byte
1313
Topics() [][]byte
1414
Data() []byte
15+
16+
Number() uint64
1517
}
1618

1719
type StateLog struct {
1820
address []byte
1921
topics [][]byte
2022
data []byte
23+
number uint64
2124
}
2225

23-
func NewLog(address []byte, topics [][]byte, data []byte) *StateLog {
24-
return &StateLog{address, topics, data}
26+
func NewLog(address []byte, topics [][]byte, data []byte, number uint64) *StateLog {
27+
return &StateLog{address, topics, data, number}
2528
}
2629

2730
func (self *StateLog) Address() []byte {
@@ -36,6 +39,10 @@ func (self *StateLog) Data() []byte {
3639
return self.data
3740
}
3841

42+
func (self *StateLog) Number() uint64 {
43+
return self.number
44+
}
45+
3946
func NewLogFromValue(decoder *ethutil.Value) *StateLog {
4047
log := &StateLog{
4148
address: decoder.Get(0).Bytes(),

vm/environment.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type Log struct {
5454
address []byte
5555
topics [][]byte
5656
data []byte
57+
log uint64
5758
}
5859

5960
func (self *Log) Address() []byte {
@@ -68,6 +69,10 @@ func (self *Log) Data() []byte {
6869
return self.data
6970
}
7071

72+
func (self *Log) Number() uint64 {
73+
return self.log
74+
}
75+
7176
func (self *Log) RlpData() interface{} {
7277
return []interface{}{self.address, ethutil.ByteSliceToInterface(self.topics), self.data}
7378
}

vm/vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
578578
}
579579

580580
data := mem.Get(mStart.Int64(), mSize.Int64())
581-
log := &Log{context.Address(), topics, data}
581+
log := &Log{context.Address(), topics, data, self.env.BlockNumber().Uint64()}
582582
self.env.AddLog(log)
583583

584584
self.Printf(" => %v", log)

0 commit comments

Comments
 (0)