erigon-pulse/turbo/builder/latest_block_built.go

30 lines
508 B
Go
Raw Normal View History

package builder
import (
"sync"
"github.com/ledgerwatch/erigon/core/types"
)
type LatestBlockBuiltStore struct {
block *types.Block
lock sync.Mutex
}
func NewLatestBlockBuiltStore() *LatestBlockBuiltStore {
return &LatestBlockBuiltStore{}
}
func (s *LatestBlockBuiltStore) AddBlockBuilt(block *types.Block) {
s.lock.Lock()
defer s.lock.Unlock()
s.block = block.Copy()
}
func (s *LatestBlockBuiltStore) BlockBuilt() *types.Block {
s.lock.Lock()
defer s.lock.Unlock()
return s.block.Copy()
}