From 3642441ca3a0afe94e581612ff99aef7f0e66a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 20 Jul 2015 14:02:02 +0300 Subject: [PATCH] xeth: fix #1485, data race in fiilter creation and event firing --- xeth/xeth.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xeth/xeth.go b/xeth/xeth.go index 19d9c0ad46..34409a1487 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -518,6 +518,9 @@ func (self *XEth) UninstallFilter(id int) bool { } func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address []string, topics [][]string) int { + self.logMu.Lock() + defer self.logMu.Unlock() + var id int filter := core.NewFilter(self.backend) filter.SetEarliestBlock(earliest) @@ -539,6 +542,9 @@ func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address [] } func (self *XEth) NewTransactionFilter() int { + self.transactionMu.Lock() + defer self.transactionMu.Unlock() + var id int filter := core.NewFilter(self.backend) filter.TransactionCallback = func(tx *types.Transaction) { @@ -553,6 +559,9 @@ func (self *XEth) NewTransactionFilter() int { } func (self *XEth) NewBlockFilter() int { + self.blockMu.Lock() + defer self.blockMu.Unlock() + var id int filter := core.NewFilter(self.backend) filter.BlockCallback = func(block *types.Block, logs state.Logs) {