From 04a63a22a24abaaa91b1d981e6d95260d80dadf4 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Tue, 4 Sep 2018 17:39:05 +0800 Subject: core: BA-based consensus core. (#93) --- simulation/app.go | 2 +- simulation/tcp-network.go | 14 ++++++++++++++ simulation/verification.go | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'simulation') diff --git a/simulation/app.go b/simulation/app.go index aded2a7..4bf4aff 100644 --- a/simulation/app.go +++ b/simulation/app.go @@ -116,7 +116,7 @@ func (a *simApp) TotalOrderingDeliver(blockHashes common.Hashes, early bool) { } a.Outputs = blocks a.Early = early - //fmt.Println("OUTPUT", a.ValidatorID, a.Early, a.Outputs) + fmt.Println("OUTPUT", a.ValidatorID, a.Early, a.Outputs) confirmLatency := []time.Duration{} diff --git a/simulation/tcp-network.go b/simulation/tcp-network.go index 31c8d95..468baff 100644 --- a/simulation/tcp-network.go +++ b/simulation/tcp-network.go @@ -168,6 +168,20 @@ func (n *TCPNetwork) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } n.recieveChan <- block + case "vote": + vote := &types.Vote{} + if err := json.Unmarshal(m.Payload, vote); err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + n.recieveChan <- vote + case "notaryAck": + ack := &types.NotaryAck{} + if err := json.Unmarshal(m.Payload, ack); err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + n.recieveChan <- ack default: w.WriteHeader(http.StatusBadRequest) return diff --git a/simulation/verification.go b/simulation/verification.go index ad2c911..2e90b8b 100644 --- a/simulation/verification.go +++ b/simulation/verification.go @@ -202,7 +202,7 @@ func VerifyTotalOrder(id types.ValidatorID, if hasError { log.Printf("[%d] Hash is %v from %v\n", i, hash, id) } else { - //log.Printf("Block %v confirmed\n", hash) + log.Printf("Block %v confirmed\n", hash) } } -- cgit v1.2.3