all: separate catalyst package (#24280)

* all: seperate catalyst package

* eth/catalyst: moved some methods, added docs

* eth/catalyst, les/catalyst: add method docs

* core, eth, les, miner: move common function to beacon package

* eth/catalyst: goimported

* cmd/utils, miner/stress/beacon: naming nitpicks

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
rjl493456442
2022-01-31 20:22:35 +08:00
committed by GitHub
parent a5c0cfb451
commit 9da25c5db7
11 changed files with 703 additions and 322 deletions

View File

@ -16,7 +16,11 @@
package catalyst
import "sync"
import (
"sync"
"github.com/ethereum/go-ethereum/core/beacon"
)
// maxTrackedPayloads is the maximum number of prepared payloads the execution
// engine tracks before evicting old ones. Ideally we should only ever track the
@ -26,8 +30,8 @@ const maxTrackedPayloads = 10
// payloadQueueItem represents an id->payload tuple to store until it's retrieved
// or evicted.
type payloadQueueItem struct {
id PayloadID
payload *ExecutableDataV1
id beacon.PayloadID
payload *beacon.ExecutableDataV1
}
// payloadQueue tracks the latest handful of constructed payloads to be retrieved
@ -46,7 +50,7 @@ func newPayloadQueue() *payloadQueue {
}
// put inserts a new payload into the queue at the given id.
func (q *payloadQueue) put(id PayloadID, data *ExecutableDataV1) {
func (q *payloadQueue) put(id beacon.PayloadID, data *beacon.ExecutableDataV1) {
q.lock.Lock()
defer q.lock.Unlock()
@ -58,7 +62,7 @@ func (q *payloadQueue) put(id PayloadID, data *ExecutableDataV1) {
}
// get retrieves a previously stored payload item or nil if it does not exist.
func (q *payloadQueue) get(id PayloadID) *ExecutableDataV1 {
func (q *payloadQueue) get(id beacon.PayloadID) *beacon.ExecutableDataV1 {
q.lock.RLock()
defer q.lock.RUnlock()