prysm-pulse/sharding/listener.go
Raul Jordan c147675ec3 subscribe to new block headers for eligible proposer
Former-commit-id: c9eea106dac51f1d9a91fa16bc0c9a700d6a740d [formerly 86b5dab0dd01a8c5199dd7c5b06c86a4cc022369]
Former-commit-id: 5ee1c82975c61976e47efeac40e060a11f15e1df
2018-01-28 15:57:20 -06:00

33 lines
904 B
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()))
}
}
}