mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
9969f7e9bf
Former-commit-id: 7d85080fc0d3b82a0bcf5b60546f22d0e78cd9e3 [formerly 7b659786136a9451a7980cb447128ad4f059efd1] Former-commit-id: 9844823e588bf0d9127fb4019bd66812b6527411
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
// Package notary defines all relevant functionality for a Notary actor
|
|
// within a sharded Ethereum blockchain.
|
|
package notary
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/sharding"
|
|
"github.com/ethereum/go-ethereum/sharding/database"
|
|
"github.com/ethereum/go-ethereum/sharding/mainchain"
|
|
)
|
|
|
|
// 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 *mainchain.SMCClient
|
|
shardp2p sharding.ShardP2P
|
|
shardChainDb database.ShardBackend
|
|
}
|
|
|
|
// NewNotary creates a new notary instance.
|
|
func NewNotary(smcClient *mainchain.SMCClient, shardp2p sharding.ShardP2P, shardChainDb database.ShardBackend) (*Notary, error) {
|
|
return &Notary{smcClient, shardp2p, shardChainDb}, 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
|
|
// are blocking.
|
|
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
|
|
}
|