forked from TrueCloudLab/frostfs-node
[#1213] morph/client: Protect cached values with a mutex
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
a8d2001b35
commit
9bbb136e4a
2 changed files with 23 additions and 7 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
|
@ -43,8 +44,11 @@ type Client struct {
|
|||
}
|
||||
|
||||
type cache struct {
|
||||
nnsHash util.Uint160
|
||||
groupKey *keys.PublicKey
|
||||
// mtx protects primitive values.
|
||||
mtx sync.RWMutex
|
||||
nnsHash util.Uint160
|
||||
groupKey *keys.PublicKey
|
||||
// txHeights is a thread-safe LRU cache for transaction heights.
|
||||
txHeights *lru.Cache
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue