prysm-pulse/sharding/notary/service.go
Raul Jordan cbfdd4807e sharding: register actor services, modularize services
Former-commit-id: 2513b3150392096adf0ac8e43349a1ff046f941c [formerly ddfe2a5c70a4b28c60d4321d87dc4a2a512fdb72]
Former-commit-id: 07ffa1c5adf2ab34760d975110d08ddabf2c3d95
2018-06-04 16:34:48 -04:00

41 lines
1.0 KiB
Go

package notary
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding"
)
// 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 {
smcClient sharding.SMCClient
}
// NewNotary creates a new notary instance.
func NewNotary(smcClient sharding.SMCClient) (*Notary, error) {
return &Notary{smcClient}, 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.smcClient.DepositFlag() {
if err := joinNotaryPool(n.smcClient); err != nil {
return err
}
}
return subscribeBlockHeaders(n.smcClient)
}
// Stop the main loop for notarizing collations.
func (n *Notary) Stop() error {
log.Info("Stopping notary service")
return nil
}