cache: fieldalign (#692)

```bash
$ fieldalignment -fix kv/kvcache/cache.go
/Users/estensen/Developer/erigon-lib/kv/kvcache/cache.go:88:15: struct with 208 pointer bytes could be 144
/Users/estensen/Developer/erigon-lib/kv/kvcache/cache.go:117:19: struct with 32 pointer bytes could be 24
/Users/estensen/Developer/erigon-lib/kv/kvcache/cache.go:131:21: struct with 24 pointer bytes could be 8

// had to re-add comments in fields
```

I can do the rest of the packages too if it's interesting?
This commit is contained in:
Håvard Anda Estensen 2022-10-21 07:56:23 +02:00 committed by GitHub
parent fcd7314c39
commit 16a85ce522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,17 +86,23 @@ type CacheView interface {
// - changes in Canonical View SHOULD reflect in stateEvict
// - changes in Non-Canonical View SHOULD NOT reflect in stateEvict
type Coherent struct {
hits, miss, timeout *metrics.Counter
keys, evict *metrics.Counter
codeHits, codeMiss, codeKeys *metrics.Counter
codeEvictLen *metrics.Counter
latestStateView *CoherentRoot
roots map[ViewID]*CoherentRoot
stateEvict, codeEvict *ThreadSafeEvictionList
lock sync.RWMutex
cfg CoherentConfig
latestViewID ViewID
hasher hash.Hash
hasher hash.Hash
codeEvictLen *metrics.Counter
codeKeys *metrics.Counter
keys *metrics.Counter
evict *metrics.Counter
latestStateView *CoherentRoot
codeMiss *metrics.Counter
timeout *metrics.Counter
hits *metrics.Counter
codeHits *metrics.Counter
roots map[ViewID]*CoherentRoot
stateEvict *ThreadSafeEvictionList
codeEvict *ThreadSafeEvictionList
miss *metrics.Counter
cfg CoherentConfig
latestViewID ViewID
lock sync.RWMutex
}
type CoherentRoot struct {
@ -115,9 +121,9 @@ type CoherentRoot struct {
// CoherentView - dumb object, which proxy all requests to Coherent object.
// It's thread-safe, because immutable
type CoherentView struct {
viewID ViewID
cache *Coherent
tx kv.Tx
cache *Coherent
viewID ViewID
}
func (c *CoherentView) Get(k []byte) ([]byte, error) { return c.cache.Get(k, c.tx, c.viewID) }
@ -129,12 +135,12 @@ var _ CacheView = (*CoherentView)(nil) // compile-time interface check
const DEGREE = 32
type CoherentConfig struct {
MetricsLabel string
KeepViews uint64 // keep in memory up to this amount of views, evict older
NewBlockWait time.Duration // how long wait
MetricsLabel string
WithStorage bool
KeysLimit int
CodeKeysLimit int
WithStorage bool
}
var DefaultCoherentConfig = CoherentConfig{