2018-05-22 11:34:12 +00:00
|
|
|
package proposer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2018-06-04 21:10:59 +00:00
|
|
|
"github.com/ethereum/go-ethereum/sharding"
|
2018-05-22 11:34:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Proposer holds functionality required to run a collation proposer
|
|
|
|
// in a sharded system. Must satisfy the Service interface defined in
|
|
|
|
// sharding/service.go.
|
2018-06-04 21:10:59 +00:00
|
|
|
type Proposer struct {
|
2018-06-04 21:19:16 +00:00
|
|
|
client sharding.SMCClient
|
2018-06-04 21:10:59 +00:00
|
|
|
shardp2p sharding.ShardP2P
|
|
|
|
txpool sharding.TXPool
|
|
|
|
}
|
2018-05-22 11:34:12 +00:00
|
|
|
|
|
|
|
// 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.
|
2018-06-04 21:19:16 +00:00
|
|
|
func NewProposer(client sharding.SMCClient, shardp2p sharding.ShardP2P, txpool sharding.TXPool) (*Proposer, error) {
|
2018-06-02 22:29:35 +00:00
|
|
|
// Initializes a directory persistent db.
|
2018-06-04 21:19:16 +00:00
|
|
|
return &Proposer{client, shardp2p, txpool}, nil
|
2018-05-22 11:34:12 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 12:47:35 +00:00
|
|
|
// Start the main loop for proposing collations.
|
2018-05-22 11:34:12 +00:00
|
|
|
func (p *Proposer) Start() error {
|
2018-05-22 12:47:35 +00:00
|
|
|
log.Info("Starting proposer service")
|
|
|
|
// TODO: Propose collations.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop the main loop for proposing collations.
|
|
|
|
func (p *Proposer) Stop() error {
|
|
|
|
log.Info("Stopping proposer service")
|
2018-05-22 11:34:12 +00:00
|
|
|
return nil
|
|
|
|
}
|