prysm-pulse/sharding/notary/notary_client.go
Preston Van Loon a4a0ca98dd Sharding: only deposit when --deposit is present (#115)
Former-commit-id: ea182c0890138082396b4d06d543a9929efa73de [formerly fbb923ff61f07a4e2cd6022069d7b29fca244c02]
Former-commit-id: 6b9769d4250599a6720cbdceb3e41459d7b1b5da
2018-05-13 12:33:29 -04:00

43 lines
785 B
Go

package notary
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding/client"
cli "gopkg.in/urfave/cli.v1"
)
// Notary runnable client.
type Notary interface {
// Start the main routine for a notary.
Start() error
}
type notary struct {
client client.Client
}
// NewNotary creates a new notary instance.
func NewNotary(ctx *cli.Context) Notary {
return &notary{
client: client.NewClient(ctx),
}
}
// Start the main routine for a notary.
func (c *notary) Start() error {
log.Info("Starting notary client")
err := c.client.Start()
if err != nil {
return err
}
defer c.client.Close()
if c.client.DepositFlagSet() {
if err := joinNotaryPool(c.client); err != nil {
return err
}
}
return subscribeBlockHeaders(c.client)
}