2018-03-31 04:07:42 +00:00
|
|
|
package collator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/sharding/client"
|
2018-03-31 06:13:51 +00:00
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2018-03-31 04:07:42 +00:00
|
|
|
cli "gopkg.in/urfave/cli.v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewCollatorClient(ctx *cli.Context) *client.ShardingClient {
|
|
|
|
c := client.MakeClient(ctx)
|
|
|
|
return c
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func CollatorStart(sclient *client.ShardingClient) error {
|
2018-03-31 06:13:51 +00:00
|
|
|
log.Info("Starting collator client")
|
|
|
|
rpcClient, err := sclient.Start()
|
|
|
|
defer rpcClient.Close()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-31 04:07:42 +00:00
|
|
|
|
|
|
|
if err := joinCollatorPool(sclient); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := subscribeBlockHeaders(sclient); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|