mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
319ba38250
Former-commit-id: a408cce4805fab38dd0d52d8743c4d00b82133ee [formerly 01b8b29da9443a10ba632f386385e4bc9fc86a84] Former-commit-id: a88f703397c4f0a90414b1769a499bd108dcff05
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package sharding
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
"github.com/ethereum/go-ethereum/log"
|
|
)
|
|
|
|
// subscribeBlockHeaders checks incoming block headers and determines if
|
|
// we are an eligible proposer for collations. Then, it finds the pending tx's
|
|
// from the running geth node and sorts them by descending order of gas price,
|
|
// eliminates those that ask for too much gas, and routes them over
|
|
// to the VMC to create a collation
|
|
func subscribeBlockHeaders(c *Client) error {
|
|
headerChan := make(chan *types.Header, 16)
|
|
|
|
_, err := c.client.SubscribeNewHead(context.Background(), headerChan)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
log.Info("listening for new headers...")
|
|
|
|
for {
|
|
select {
|
|
case head := <-headerChan:
|
|
// Query the current state to see if we are an eligible proposer
|
|
log.Info(fmt.Sprintf("received new header %v", head.Number.String()))
|
|
// TODO: Only run this code on certain periods?
|
|
watchShards(head)
|
|
}
|
|
}
|
|
}
|
|
|
|
// watchShards checks if we are an eligible proposer for collation for
|
|
// the available shards in the VMC. The function calls getEligibleProposer from
|
|
// the VMC and proposes a collation if conditions are met
|
|
func watchShards(head types.Header) {
|
|
|
|
}
|