mocknet: fix data race

This commit is contained in:
Steven Allen 2019-03-06 11:08:14 -08:00
parent 8c8f08e36f
commit 58f40b9d11
1 changed files with 6 additions and 0 deletions

View File

@ -76,15 +76,21 @@ func (l *link) Peers() []peer.ID {
}
func (l *link) SetOptions(o LinkOptions) {
l.Lock()
defer l.Unlock()
l.opts = o
l.ratelimiter.UpdateBandwidth(l.opts.Bandwidth)
}
func (l *link) Options() LinkOptions {
l.RLock()
defer l.RUnlock()
return l.opts
}
func (l *link) GetLatency() time.Duration {
l.RLock()
defer l.RUnlock()
return l.opts.Latency
}