mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
72bd785a2e
Former-commit-id: 970a229ed8d1cce8c5383a40e313092828c1be69 [formerly 0f30c11d3352946caccc1d325a0551f43dc8439c] Former-commit-id: 6ca7badf14c01fabf6a63db26214b6a0179aa8f2
42 lines
868 B
Go
42 lines
868 B
Go
// Package collator holds all of the functionality to run as a collator in a sharded system.
|
|
package collator
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/sharding/client"
|
|
cli "gopkg.in/urfave/cli.v1"
|
|
)
|
|
|
|
// Collator runnable client.
|
|
type Collator interface {
|
|
// Start the main routine for a collator.
|
|
Start() error
|
|
}
|
|
|
|
type collator struct {
|
|
client client.Client
|
|
}
|
|
|
|
// NewCollator creates a new collator instance.
|
|
func NewCollator(ctx *cli.Context) Collator {
|
|
return &collator{
|
|
client: client.NewClient(ctx),
|
|
}
|
|
}
|
|
|
|
// Start the main routine for a collator.
|
|
func (c *collator) Start() error {
|
|
log.Info("Starting collator client")
|
|
err := c.client.Start()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer c.client.Close()
|
|
|
|
if err := joinCollatorPool(c.client); err != nil {
|
|
return err
|
|
}
|
|
|
|
return subscribeBlockHeaders(c.client)
|
|
}
|