2018-06-05 23:03:15 +00:00
|
|
|
// Package proposer defines all relevant functionality for a Proposer actor
|
2018-06-05 21:28:57 +00:00
|
|
|
// within the minimal sharding protocol.
|
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-06-05 23:03:15 +00:00
|
|
|
"github.com/ethereum/go-ethereum/sharding/mainchain"
|
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-07 06:03:54 +00:00
|
|
|
client *mainchain.SMCClient
|
2018-06-04 21:10:59 +00:00
|
|
|
shardp2p sharding.ShardP2P
|
|
|
|
txpool sharding.TXPool
|
|
|
|
}
|
2018-05-22 11:34:12 +00:00
|
|
|
|
2018-06-06 02:03:58 +00:00
|
|
|
// NewProposer creates a struct instance of a proposer service.
|
|
|
|
// It will have access to a mainchain client, a shardp2p network,
|
|
|
|
// and a shard transaction pool.
|
2018-06-07 06:03:54 +00:00
|
|
|
func NewProposer(client *mainchain.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
|
|
|
|
}
|