Commit 3642441c authored by Péter Szilágyi's avatar Péter Szilágyi

xeth: fix #1485, data race in fiilter creation and event firing

parent 12bb743b
...@@ -518,6 +518,9 @@ func (self *XEth) UninstallFilter(id int) bool { ...@@ -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 { 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 var id int
filter := core.NewFilter(self.backend) filter := core.NewFilter(self.backend)
filter.SetEarliestBlock(earliest) filter.SetEarliestBlock(earliest)
...@@ -539,6 +542,9 @@ func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address [] ...@@ -539,6 +542,9 @@ func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address []
} }
func (self *XEth) NewTransactionFilter() int { func (self *XEth) NewTransactionFilter() int {
self.transactionMu.Lock()
defer self.transactionMu.Unlock()
var id int var id int
filter := core.NewFilter(self.backend) filter := core.NewFilter(self.backend)
filter.TransactionCallback = func(tx *types.Transaction) { filter.TransactionCallback = func(tx *types.Transaction) {
...@@ -553,6 +559,9 @@ func (self *XEth) NewTransactionFilter() int { ...@@ -553,6 +559,9 @@ func (self *XEth) NewTransactionFilter() int {
} }
func (self *XEth) NewBlockFilter() int { func (self *XEth) NewBlockFilter() int {
self.blockMu.Lock()
defer self.blockMu.Unlock()
var id int var id int
filter := core.NewFilter(self.backend) filter := core.NewFilter(self.backend)
filter.BlockCallback = func(block *types.Block, logs state.Logs) { filter.BlockCallback = func(block *types.Block, logs state.Logs) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment