Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak committed Oct 24, 2023
1 parent 85e48c8 commit 25807b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
12 changes: 6 additions & 6 deletions atxsdata/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package atxsdata

import (
"sync"

"go.uber.org/atomic"
"sync/atomic"

"github.com/spacemeshos/go-spacemesh/common/types"
)
Expand Down Expand Up @@ -74,15 +73,16 @@ func (d *Data) IsEvicted(epoch types.EpochID) bool {
// OnEpoch is a notification for cache to evict epochs that are not useful
// to keep in memory.
func (d *Data) OnEpoch(applied types.EpochID) {
d.mu.Lock()
defer d.mu.Unlock()
if applied < d.capacity {
return
}
evict := applied - d.capacity
if d.IsEvicted(evict) {
return
}

d.mu.Lock()
defer d.mu.Unlock()
if d.evicted.Load() < evict.Uint32() {
d.evicted.Store(evict.Uint32())
}
Expand All @@ -102,11 +102,11 @@ func (d *Data) Add(
nonce types.VRFPostIndex,
malicious bool,
) {
d.mu.Lock()
defer d.mu.Unlock()
if d.IsEvicted(epoch) {
return
}
d.mu.Lock()
defer d.mu.Unlock()
ecache, exists := d.epochs[epoch]
if !exists {
ecache = epochCache{
Expand Down
10 changes: 0 additions & 10 deletions atxsdata/warmup.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,3 @@ func Warmup(db sql.Executor, cache *Data) error {
}
return ierr
}

func ToATXData(atx *types.ActivationTxHeader, nonce types.VRFPostIndex, malicious bool) *ATX {
return &ATX{
Weight: atx.GetWeight(),
BaseHeight: atx.BaseTickHeight,
Height: atx.TickHeight(),
Nonce: nonce,
Malicious: malicious,
}
}

0 comments on commit 25807b0

Please sign in to comment.