sharding: refactor proposers

Former-commit-id: 27b5dfe6a36681e873a11887690428e255df1d97 [formerly 6394a809217dc1450fdfb1d6de7f91153afd6eaf]
Former-commit-id: 57f44262b2223ddefa48558d0b4e9cfa6b85d00c
This commit is contained in:
Raul Jordan 2018-05-22 06:34:12 -05:00
parent bb95a087d4
commit 65c7c390a5
3 changed files with 30 additions and 38 deletions

View File

@ -112,6 +112,7 @@ func (n *shardingNode) registerShardingServices() error {
clientType := n.ctx.GlobalString(utils.ClientType.Name)
err := n.Register(func(ctx *node.ServiceContext) (node.Service, error) {
// TODO(terenc3t): handle case when we just want to start an observer node.
if clientType == "notary" {
return notary.NewNotary(n.ctx)
}

View File

@ -0,0 +1,29 @@
package proposer
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding/node"
"github.com/ethereum/go-ethereum/swarm/api/client"
cli "gopkg.in/urfave/cli.v1"
)
// Proposer holds functionality required to run a collation proposer
// in a sharded system. Must satisfy the Service interface defined in
// sharding/service.go.
type Proposer struct {
client client.Client
}
// NewProposer creates a struct instance. It is initialized and
// registered as a service upon start of a sharding node.
// Has access to the public methods of this node.
func NewProposer(ctx *cli.Context, node node.Node) *Proposer {
return &Proposer{}
}
// Start the main entry point for proposing collations.
func (p *Proposer) Start() error {
log.Info("Starting proposer client")
// TODO: Propose collations.
return nil
}

View File

@ -1,38 +0,0 @@
package proposer
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/sharding/client"
cli "gopkg.in/urfave/cli.v1"
)
// Proposer holds functionality required to run a collation proposer
// in a sharded system.
type Proposer interface {
Start() error
}
type proposer struct {
client client.Client
}
// NewProposer creates a struct instance.
func NewProposer(ctx *cli.Context) Proposer {
return &proposer{
client: client.NewClient(ctx),
}
}
// Start the main entry point for proposing collations.
func (p *proposer) Start() error {
log.Info("Starting proposer client")
err := p.client.Start()
if err != nil {
return err
}
defer p.client.Close()
// TODO: Propose collations.
return nil
}