prysm-pulse/sharding/notary/service.go
Raul Jordan 3b19aa7c03 sharding: fully functional start func in notary service
Former-commit-id: 0755ae70512ad06ee0710f20136883ecacc8cf63 [formerly 7d558c0b4d2dd5302eaf2b8e9f8d51224ffc3858]
Former-commit-id: 3c6b00e5d5e3547260e6e0c1122ef64be08a40c1
2018-05-22 07:56:56 -05:00

43 lines
1.1 KiB
Go

package notary
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding/node"
cli "gopkg.in/urfave/cli.v1"
)
// Notary holds functionality required to run a collation notary
// in a sharded system. Must satisfy the Service interface defined in
// sharding/service.go.
type Notary struct {
node node.Node
}
// NewNotary creates a new notary instance.
func NewNotary(ctx *cli.Context, node node.Node) (*Notary, error) {
return &Notary{node}, nil
}
// Start the main routine for a notary.
func (n *Notary) Start() error {
log.Info("Starting notary service")
// TODO: handle this better through goroutines. Right now, these methods
// have their own nested channels and goroutines within them. We need
// to make this as flat as possible at the Notary layer.
if n.node.DepositFlagSet() {
if err := joinNotaryPool(n.node); err != nil {
return err
}
}
return subscribeBlockHeaders(n.node)
}
// Stop the main loop for notarizing collations.
func (n *Notary) Stop() error {
log.Info("Stopping notary service")
// TODO: Propose collations.
return nil
}