mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
trie/utils: address comment from martin
This commit is contained in:
parent
8754ebc168
commit
1379079d5b
1 changed files with 4 additions and 12 deletions
|
|
@ -84,28 +84,20 @@ func NewPointCache(maxItems int) *PointCache {
|
|||
}
|
||||
}
|
||||
|
||||
// get loads the cached commitment, or nil if it's not existent.
|
||||
func (c *PointCache) get(addr string) (*verkle.Point, bool) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
|
||||
return c.lru.Get(addr)
|
||||
}
|
||||
|
||||
// Get returns the cached commitment for the specified address, or computing
|
||||
// it on the flight.
|
||||
func (c *PointCache) Get(addr []byte) *verkle.Point {
|
||||
p, ok := c.get(string(addr))
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
p, ok := c.lru.Get(string(addr))
|
||||
if ok {
|
||||
cacheHitGauge.Inc(1)
|
||||
return p
|
||||
}
|
||||
cacheMissGauge.Inc(1)
|
||||
p = evaluateAddressPoint(addr)
|
||||
|
||||
c.lock.Lock()
|
||||
c.lru.Add(string(addr), p)
|
||||
c.lock.Unlock()
|
||||
return p
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue