mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
6272559fb7
Instead of getting the pending block with latest payload id, we just store the latest block built and serve it in remote backend
30 lines
508 B
Go
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()
|
|
}
|