erigon-pulse/turbo/builder/latest_block_built.go
Giulio rebuffo 6272559fb7
Separated PendingBlock behaviour to be chain agnostic (#7859)
Instead of getting the pending block with latest payload id, we just
store the latest block built and serve it in remote backend
2023-07-10 19:22:03 +02:00

30 lines
508 B
Go

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()
}