mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
3861c0cf06
Former-commit-id: 0ecc597de035e61ca219f4f30695cb8db59c129b [formerly da9312c1c9d69010083f94f387fe6a52aa817683] Former-commit-id: 8c8c218e16ef248ae8954168cf7bf5aa6ed6839d
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
// Package notary defines all relevant functionality for a Notary actor
|
|
// within the minimal sharding protocol.
|
|
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
|
|
shardp2p sharding.ShardP2P
|
|
}
|
|
|
|
// NewNotary creates a new notary instance.
|
|
func NewNotary(smcClient sharding.SMCClient, shardp2p sharding.ShardP2P) (*Notary, error) {
|
|
return &Notary{smcClient, shardp2p}, 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
|
|
}
|