prysm-pulse/sharding/notary/notary_client.go
Terence Tsao 8bff6099c6 sharding/contracts: merge with master
Former-commit-id: 251eebf6cb46497e3afda66e0496ebd04593a741 [formerly 3399601d0fd7263f99ad2a6c0e9935e1ad0139a9]
Former-commit-id: e92aa0f01cd90b73684d5f3b3d8b127ae5130b1b
2018-05-13 15:53:52 -07: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)
}