mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
dd384d3a22
Former-commit-id: b2defb3e277217d0d5bef86f1d4078668791d251 [formerly 6a6bd5c309442805ccac942325e0feef69dd17ab] Former-commit-id: 2a26568478ed072db7c8e299eb40644b1c7c10d2
41 lines
1.0 KiB
Go
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 {
|
|
node sharding.ShardingClient
|
|
}
|
|
|
|
// NewNotary creates a new notary instance.
|
|
func NewNotary(node sharding.ShardingClient) (*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")
|
|
return nil
|
|
}
|