2018-05-22 11:34:12 +00:00
|
|
|
package proposer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2018-05-25 15:52:18 +00:00
|
|
|
"github.com/ethereum/go-ethereum/sharding/database"
|
2018-05-22 12:47:35 +00:00
|
|
|
"github.com/ethereum/go-ethereum/sharding/node"
|
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.
|
|
|
|
type Proposer struct {
|
2018-05-25 15:52:18 +00:00
|
|
|
node node.Node
|
|
|
|
shardDB database.ShardBackend
|
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-05-22 22:12:02 +00:00
|
|
|
func NewProposer(node node.Node) (*Proposer, error) {
|
2018-05-25 15:52:18 +00:00
|
|
|
shardDB, err := database.NewShardDB(node.DataDirFlag(), "shardchaindata")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &Proposer{node, shardDB}, 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
|
|
|
|
}
|