aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
Diffstat (limited to 'simulation')
-rw-r--r--simulation/network.go1
-rw-r--r--simulation/tcp-network.go14
-rw-r--r--simulation/validator.go4
3 files changed, 19 insertions, 0 deletions
diff --git a/simulation/network.go b/simulation/network.go
index f08b638..687dd90 100644
--- a/simulation/network.go
+++ b/simulation/network.go
@@ -81,6 +81,7 @@ type Network interface {
Join(endpoint Endpoint) chan interface{}
BroadcastBlock(block *types.Block)
BroadcastNotaryAck(notaryAck *types.NotaryAck)
+ BroadcastVote(vote *types.Vote)
Endpoints() types.ValidatorIDs
}
diff --git a/simulation/tcp-network.go b/simulation/tcp-network.go
index 2da9e3a..bb63bd1 100644
--- a/simulation/tcp-network.go
+++ b/simulation/tcp-network.go
@@ -257,6 +257,9 @@ func (n *TCPNetwork) Send(destID types.ValidatorID, msg interface{}) {
case *types.NotaryAck:
message.Type = "notaryAck"
message.Payload = v
+ case *types.Vote:
+ message.Type = "vote"
+ message.Payload = v
default:
fmt.Println("error: invalid message type")
return
@@ -318,6 +321,17 @@ func (n *TCPNetwork) BroadcastNotaryAck(notaryAck *types.NotaryAck) {
}
}
+// BroadcastVote broadcast vote into the network.
+func (n *TCPNetwork) BroadcastVote(vote *types.Vote) {
+ vote = vote.Clone()
+ for endpoint := range n.endpoints {
+ if endpoint == vote.ProposerID {
+ continue
+ }
+ n.Send(endpoint, vote)
+ }
+}
+
// DeliverBlocks sends blocks to peerServer.
func (n *TCPNetwork) DeliverBlocks(blocks BlockList) {
messageJSON, err := json.Marshal(blocks)
diff --git a/simulation/validator.go b/simulation/validator.go
index fb5f6cd..b26603a 100644
--- a/simulation/validator.go
+++ b/simulation/validator.go
@@ -159,6 +159,10 @@ func (v *Validator) MsgServer(
if err := v.consensus.ProcessNotaryAck(val); err != nil {
fmt.Println(err)
}
+ case *types.Vote:
+ if err := v.consensus.ProcessVote(val); err != nil {
+ fmt.Println(err)
+ }
}
}
}