Skip to content

Commit 996cf5c

Browse files
committed
eth/catalyst: add peek method to payloadQueue to return Miner.Payload
1 parent 77f390d commit 996cf5c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

eth/catalyst/queue.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ func (q *payloadQueue) get(id engine.PayloadID, full bool) *engine.ExecutionPayl
9595
return nil
9696
}
9797

98+
// peek retrieves a previously stored payload itself or nil if it does not exist.
99+
func (q *payloadQueue) peek(id engine.PayloadID) *miner.Payload {
100+
q.lock.RLock()
101+
defer q.lock.RUnlock()
102+
103+
for _, item := range q.payloads {
104+
if item == nil {
105+
return nil // no more items
106+
}
107+
if item.id == id {
108+
return item.payload
109+
}
110+
}
111+
return nil
112+
}
113+
98114
// has checks if a particular payload is already tracked.
99115
func (q *payloadQueue) has(id engine.PayloadID) bool {
100116
q.lock.RLock()

0 commit comments

Comments
 (0)