Skip to content

Commit ab85a35

Browse files
committed
Merge pull request #1545 from obscuren/log-index
core/state: Set log index. Closes #1226
2 parents c1c06ff + f715547 commit ab85a35

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/state/statedb.go

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type StateDB struct {
4444
thash, bhash common.Hash
4545
txIndex int
4646
logs map[common.Hash]Logs
47+
logSize uint
4748
}
4849

4950
// Create a new state from a given trie
@@ -66,7 +67,9 @@ func (self *StateDB) AddLog(log *Log) {
6667
log.TxHash = self.thash
6768
log.BlockHash = self.bhash
6869
log.TxIndex = uint(self.txIndex)
70+
log.Index = self.logSize
6971
self.logs[self.thash] = append(self.logs[self.thash], log)
72+
self.logSize++
7073
}
7174

7275
func (self *StateDB) GetLogs(hash common.Hash) Logs {
@@ -288,6 +291,7 @@ func (self *StateDB) Copy() *StateDB {
288291
state.logs[hash] = make(Logs, len(logs))
289292
copy(state.logs[hash], logs)
290293
}
294+
state.logSize = self.logSize
291295

292296
return state
293297
}
@@ -298,6 +302,7 @@ func (self *StateDB) Set(state *StateDB) {
298302

299303
self.refund = state.refund
300304
self.logs = state.logs
305+
self.logSize = state.logSize
301306
}
302307

303308
func (s *StateDB) Root() common.Hash {

0 commit comments

Comments
 (0)