mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-06 01:32:18 +00:00
9db49e8be3
Former-commit-id: cdd3520e9e4705f23addbcbee86819dcdc322182 [formerly 0ef943ecc446417babcb02f2f49a3c48ed9db772] Former-commit-id: 3dd9b81535df442cbdcd4ef6a4e043c192fbd8d0
39 lines
703 B
Go
39 lines
703 B
Go
package collator
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/sharding/client"
|
|
cli "gopkg.in/urfave/cli.v1"
|
|
)
|
|
|
|
type Collator interface {
|
|
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)
|
|
}
|