diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-09-20 09:09:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 09:09:37 +0800 |
commit | 421d72b2d796195178104a0eb1dedf319ba8664c (patch) | |
tree | f32f15c167989905494eca1891c3240b80dac1d6 /core/test/fake-transport.go | |
parent | 37f117d35c6617e1944d45e001e03813a6a278ed (diff) | |
download | dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.gz dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.bz2 dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.lz dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.xz dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.zst dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.zip |
Rename validator* to node* (#120)
Diffstat (limited to 'core/test/fake-transport.go')
-rw-r--r-- | core/test/fake-transport.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/test/fake-transport.go b/core/test/fake-transport.go index 2615bd4..2f1686e 100644 --- a/core/test/fake-transport.go +++ b/core/test/fake-transport.go @@ -28,10 +28,10 @@ import ( // by using golang channel. type FakeTransport struct { peerType TransportPeerType - vID types.ValidatorID + nID types.NodeID recvChannel chan *TransportEnvelope serverChannel chan<- *TransportEnvelope - peers map[types.ValidatorID]chan<- *TransportEnvelope + peers map[types.NodeID]chan<- *TransportEnvelope latency LatencyModel } @@ -45,19 +45,19 @@ func NewFakeTransportServer() TransportServer { // NewFakeTransportClient constructs FakeTransport instance for peer. func NewFakeTransportClient( - vID types.ValidatorID, latency LatencyModel) TransportClient { + nID types.NodeID, latency LatencyModel) TransportClient { return &FakeTransport{ peerType: TransportPeer, recvChannel: make(chan *TransportEnvelope, 1000), - vID: vID, + nID: nID, latency: latency, } } // Send implements Transport.Send method. func (t *FakeTransport) Send( - endpoint types.ValidatorID, msg interface{}) (err error) { + endpoint types.NodeID, msg interface{}) (err error) { ch, exists := t.peers[endpoint] if !exists { @@ -70,7 +70,7 @@ func (t *FakeTransport) Send( } ch <- &TransportEnvelope{ PeerType: t.peerType, - From: t.vID, + From: t.nID, Msg: msg, } }(ch) @@ -82,7 +82,7 @@ func (t *FakeTransport) Report(msg interface{}) (err error) { go func() { t.serverChannel <- &TransportEnvelope{ PeerType: TransportPeer, - From: t.vID, + From: t.nID, Msg: msg, } }() @@ -92,7 +92,7 @@ func (t *FakeTransport) Report(msg interface{}) (err error) { // Broadcast implements Transport.Broadcast method. func (t *FakeTransport) Broadcast(msg interface{}) (err error) { for k := range t.peers { - if k == t.vID { + if k == t.nID { continue } t.Send(k, msg) @@ -107,10 +107,10 @@ func (t *FakeTransport) Close() (err error) { } // Peers implements Transport.Peers method. -func (t *FakeTransport) Peers() (peers map[types.ValidatorID]struct{}) { - peers = make(map[types.ValidatorID]struct{}) - for vID := range t.peers { - peers[vID] = struct{}{} +func (t *FakeTransport) Peers() (peers map[types.NodeID]struct{}) { + peers = make(map[types.NodeID]struct{}) + for nID := range t.peers { + peers[nID] = struct{}{} } return } @@ -135,7 +135,7 @@ func (t *FakeTransport) Join( continue } if t.peers, ok = - envelope.Msg.(map[types.ValidatorID]chan<- *TransportEnvelope); !ok { + envelope.Msg.(map[types.NodeID]chan<- *TransportEnvelope); !ok { envelopes = append(envelopes, envelope) continue @@ -155,7 +155,7 @@ func (t *FakeTransport) Host() (chan *TransportEnvelope, error) { // WaitForPeers implements TransportServer.WaitForPeers method. func (t *FakeTransport) WaitForPeers(numPeers int) (err error) { - t.peers = make(map[types.ValidatorID]chan<- *TransportEnvelope) + t.peers = make(map[types.NodeID]chan<- *TransportEnvelope) for { envelope := <-t.recvChannel // Panic here if some peer send other stuffs before |