Skip to content

Commit 56edaa1

Browse files
karalabeobscuren
authored andcommitted
xeth: fix #1485, data race in fiilter creation and event firing
1 parent 8865fda commit 56edaa1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

xeth/xeth.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ func (self *XEth) UninstallFilter(id int) bool {
518518
}
519519

520520
func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address []string, topics [][]string) int {
521+
self.logMu.Lock()
522+
defer self.logMu.Unlock()
523+
521524
var id int
522525
filter := core.NewFilter(self.backend)
523526
filter.SetEarliestBlock(earliest)
@@ -539,6 +542,9 @@ func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address []
539542
}
540543

541544
func (self *XEth) NewTransactionFilter() int {
545+
self.transactionMu.Lock()
546+
defer self.transactionMu.Unlock()
547+
542548
var id int
543549
filter := core.NewFilter(self.backend)
544550
filter.TransactionCallback = func(tx *types.Transaction) {
@@ -553,6 +559,9 @@ func (self *XEth) NewTransactionFilter() int {
553559
}
554560

555561
func (self *XEth) NewBlockFilter() int {
562+
self.blockMu.Lock()
563+
defer self.blockMu.Unlock()
564+
556565
var id int
557566
filter := core.NewFilter(self.backend)
558567
filter.BlockCallback = func(block *types.Block, logs state.Logs) {

0 commit comments

Comments
 (0)