mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 19:40:36 +00:00
Use a mutex write-lock for a write operation
This commit is contained in:
parent
b143dad596
commit
09e53367a2
@ -436,15 +436,15 @@ func (self *BlacklistMap) Exists(pubkey []byte) (ok bool) {
|
||||
}
|
||||
|
||||
func (self *BlacklistMap) Put(pubkey []byte) error {
|
||||
self.lock.RLock()
|
||||
defer self.lock.RUnlock()
|
||||
self.lock.Lock()
|
||||
defer self.lock.Unlock()
|
||||
self.blacklist[string(pubkey)] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *BlacklistMap) Delete(pubkey []byte) error {
|
||||
self.lock.RLock()
|
||||
defer self.lock.RUnlock()
|
||||
self.lock.Lock()
|
||||
defer self.lock.Unlock()
|
||||
delete(self.blacklist, string(pubkey))
|
||||
return nil
|
||||
}
|
||||
|
@ -109,8 +109,8 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error
|
||||
}
|
||||
|
||||
func (self *EthereumApi) FilterChanged(id int, reply *interface{}) error {
|
||||
self.logMut.RLock()
|
||||
defer self.logMut.RUnlock()
|
||||
self.logMut.Lock()
|
||||
defer self.logMut.Unlock()
|
||||
|
||||
*reply = toLogs(self.logs[id])
|
||||
|
||||
@ -309,8 +309,8 @@ func (p *EthereumApi) NewWhisperFilter(args *xeth.Options, reply *interface{}) e
|
||||
}
|
||||
|
||||
func (self *EthereumApi) MessagesChanged(id int, reply *interface{}) error {
|
||||
self.messagesMut.RLock()
|
||||
defer self.messagesMut.RUnlock()
|
||||
self.messagesMut.Lock()
|
||||
defer self.messagesMut.Unlock()
|
||||
|
||||
*reply = self.messages[id]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user