aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-13 15:13:41 +0800
committerGitHub <noreply@github.com>2018-08-13 15:13:41 +0800
commita8ebf501e54406c7449f71dba0c9af696bbc4e21 (patch)
tree37ae1a53769d6f7be82ed576b1fd65a476c11d17 /simulation
parent63c76e56169b6f14ef049490392a1b3b414f73c6 (diff)
downloadtangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.tar
tangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.tar.gz
tangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.tar.bz2
tangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.tar.lz
tangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.tar.xz
tangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.tar.zst
tangerine-consensus-a8ebf501e54406c7449f71dba0c9af696bbc4e21.zip
core: Sign block in Consensus.PrepareBlock. (#50)
Diffstat (limited to 'simulation')
-rw-r--r--simulation/simulation.go6
-rw-r--r--simulation/validator.go9
2 files changed, 10 insertions, 5 deletions
diff --git a/simulation/simulation.go b/simulation/simulation.go
index 6730b96..fcd5dbd 100644
--- a/simulation/simulation.go
+++ b/simulation/simulation.go
@@ -53,7 +53,7 @@ func Run(configPath string) {
if err != nil {
panic(err)
}
- vs = append(vs, NewValidator(prv, cfg.Validator, network))
+ vs = append(vs, NewValidator(prv, eth.SigToPub, cfg.Validator, network))
}
} else if networkType == config.NetworkTypeTCPLocal {
for i := 0; i < cfg.Validator.Num; i++ {
@@ -63,7 +63,7 @@ func Run(configPath string) {
}
network := NewTCPNetwork(true, cfg.Networking.PeerServer)
go network.Start()
- vs = append(vs, NewValidator(prv, cfg.Validator, network))
+ vs = append(vs, NewValidator(prv, eth.SigToPub, cfg.Validator, network))
}
}
@@ -78,7 +78,7 @@ func Run(configPath string) {
}
network := NewTCPNetwork(false, cfg.Networking.PeerServer)
go network.Start()
- v := NewValidator(prv, cfg.Validator, network)
+ v := NewValidator(prv, eth.SigToPub, cfg.Validator, network)
go v.Run()
vs = append(vs, v)
}
diff --git a/simulation/validator.go b/simulation/validator.go
index c5bbe15..17d6eee 100644
--- a/simulation/validator.go
+++ b/simulation/validator.go
@@ -41,7 +41,8 @@ type Validator struct {
isFinished chan struct{}
ID types.ValidatorID
- privateKey crypto.PrivateKey
+ prvKey crypto.PrivateKey
+ sigToPub core.SigToPubFn
consensus *core.Consensus
compactionChain *core.BlockChain
}
@@ -49,6 +50,7 @@ type Validator struct {
// NewValidator returns a new empty validator.
func NewValidator(
prvKey crypto.PrivateKey,
+ sigToPub core.SigToPubFn,
config config.Validator,
network Network) *Validator {
@@ -63,6 +65,8 @@ func NewValidator(
gov.addValidator(id)
return &Validator{
ID: id,
+ prvKey: prvKey,
+ sigToPub: sigToPub,
config: config,
network: network,
app: newSimApp(id, network),
@@ -160,7 +164,8 @@ func (v *Validator) MsgServer(
// We don't collect all validators yet.
break
}
- v.consensus = core.NewConsensus(v.app, v.gov, v.db)
+ v.consensus = core.NewConsensus(
+ v.app, v.gov, v.db, v.prvKey, v.sigToPub)
for _, b := range pendingBlocks {
if err := v.consensus.ProcessBlock(b); err != nil {
fmt.Println(err)