Skip to content

Commit

Permalink
fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisMarcano-antithesis committed Oct 25, 2023
1 parent bf53047 commit c9ad0e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions op-node/p2p/store/scorebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"sync/atomic"
"github.com/ethereum-optimism/optimism/op-service/clock"
"github.com/ethereum/go-ethereum/log"
ds "github.com/ipfs/go-datastore"
Expand All @@ -23,11 +24,11 @@ type scoreRecord struct {
}

func (s *scoreRecord) SetLastUpdated(t time.Time) {
s.LastUpdate = t.Unix()
atomic.StoreInt64(&s.LastUpdate, t.Unix())
}

func (s *scoreRecord) LastUpdated() time.Time {
return time.Unix(s.LastUpdate, 0)
return time.Unix(0, atomic.LoadInt64(&s.LastUpdate))
}

func (s *scoreRecord) MarshalBinary() (data []byte, err error) {
Expand Down

0 comments on commit c9ad0e7

Please sign in to comment.