From a52f2f303eaf28d2633515a19090802deabfa67f Mon Sep 17 00:00:00 2001 From: Gabor Hosszu Date: Wed, 28 Sep 2016 15:32:34 +0200 Subject: [PATCH] Make DeliverServer public Change-Id: Icff12ae69dc7edfb7f899487188dfbcca82d66a5 Signed-off-by: Gabor Hosszu --- orderer/solo/deliver.go | 12 ++++++------ orderer/solo/deliver_test.go | 24 ++++++++++++------------ orderer/solo/solo.go | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/orderer/solo/deliver.go b/orderer/solo/deliver.go index 5e32bc8da75..bfcb06e8f25 100644 --- a/orderer/solo/deliver.go +++ b/orderer/solo/deliver.go @@ -21,19 +21,19 @@ import ( "github.com/hyperledger/fabric/orderer/rawledger" ) -type deliverServer struct { +type DeliverServer struct { rl rawledger.Reader maxWindow int } -func newDeliverServer(rl rawledger.Reader, maxWindow int) *deliverServer { - return &deliverServer{ +func NewDeliverServer(rl rawledger.Reader, maxWindow int) *DeliverServer { + return &DeliverServer{ rl: rl, maxWindow: maxWindow, } } -func (ds *deliverServer) handleDeliver(srv ab.AtomicBroadcast_DeliverServer) error { +func (ds *DeliverServer) HandleDeliver(srv ab.AtomicBroadcast_DeliverServer) error { logger.Debugf("Starting new Deliver loop") d := newDeliverer(ds, srv) return d.recv() @@ -41,7 +41,7 @@ func (ds *deliverServer) handleDeliver(srv ab.AtomicBroadcast_DeliverServer) err } type deliverer struct { - ds *deliverServer + ds *DeliverServer srv ab.AtomicBroadcast_DeliverServer cursor rawledger.Iterator nextBlockNumber uint64 @@ -51,7 +51,7 @@ type deliverer struct { exitChan chan struct{} } -func newDeliverer(ds *deliverServer, srv ab.AtomicBroadcast_DeliverServer) *deliverer { +func newDeliverer(ds *DeliverServer, srv ab.AtomicBroadcast_DeliverServer) *deliverer { d := &deliverer{ ds: ds, srv: srv, diff --git a/orderer/solo/deliver_test.go b/orderer/solo/deliver_test.go index b58938b05d7..4ac9baa186d 100644 --- a/orderer/solo/deliver_test.go +++ b/orderer/solo/deliver_test.go @@ -65,9 +65,9 @@ func TestOldestSeek(t *testing.T) { m := newMockD() defer close(m.recvChan) - ds := newDeliverServer(rl, MagicLargestWindow) + ds := NewDeliverServer(rl, MagicLargestWindow) - go ds.handleDeliver(m) + go ds.HandleDeliver(m) m.recvChan <- &ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{WindowSize: uint64(MagicLargestWindow), Start: ab.SeekInfo_OLDEST}}} @@ -97,9 +97,9 @@ func TestNewestSeek(t *testing.T) { m := newMockD() defer close(m.recvChan) - ds := newDeliverServer(rl, MagicLargestWindow) + ds := NewDeliverServer(rl, MagicLargestWindow) - go ds.handleDeliver(m) + go ds.HandleDeliver(m) m.recvChan <- &ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{WindowSize: uint64(MagicLargestWindow), Start: ab.SeekInfo_NEWEST}}} @@ -125,9 +125,9 @@ func TestSpecificSeek(t *testing.T) { } m := newMockD() - ds := newDeliverServer(rl, MagicLargestWindow) + ds := NewDeliverServer(rl, MagicLargestWindow) - go ds.handleDeliver(m) + go ds.HandleDeliver(m) m.recvChan <- &ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{WindowSize: uint64(MagicLargestWindow), Start: ab.SeekInfo_SPECIFIED, SpecifiedNumber: uint64(ledgerSize - 1)}}} @@ -154,9 +154,9 @@ func TestBadSeek(t *testing.T) { m := newMockD() defer close(m.recvChan) - ds := newDeliverServer(rl, MagicLargestWindow) + ds := NewDeliverServer(rl, MagicLargestWindow) - go ds.handleDeliver(m) + go ds.HandleDeliver(m) m.recvChan <- &ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{WindowSize: uint64(MagicLargestWindow), Start: ab.SeekInfo_SPECIFIED, SpecifiedNumber: uint64(ledgerSize - 1)}}} @@ -187,9 +187,9 @@ func TestBadWindow(t *testing.T) { m := newMockD() defer close(m.recvChan) - ds := newDeliverServer(rl, MagicLargestWindow) + ds := NewDeliverServer(rl, MagicLargestWindow) - go ds.handleDeliver(m) + go ds.HandleDeliver(m) m.recvChan <- &ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{WindowSize: uint64(MagicLargestWindow) * 2, Start: ab.SeekInfo_OLDEST}}} @@ -213,9 +213,9 @@ func TestAck(t *testing.T) { m := newMockD() defer close(m.recvChan) - ds := newDeliverServer(rl, MagicLargestWindow) + ds := NewDeliverServer(rl, MagicLargestWindow) - go ds.handleDeliver(m) + go ds.HandleDeliver(m) m.recvChan <- &ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{WindowSize: windowSize, Start: ab.SeekInfo_OLDEST}}} diff --git a/orderer/solo/solo.go b/orderer/solo/solo.go index d8b0a326e88..aca26cd8acb 100644 --- a/orderer/solo/solo.go +++ b/orderer/solo/solo.go @@ -36,7 +36,7 @@ func init() { type server struct { bs *broadcastServer - ds *deliverServer + ds *DeliverServer } // New creates a ab.AtomicBroadcastServer based on the solo orderer implementation @@ -44,7 +44,7 @@ func New(queueSize, batchSize, maxWindowSize int, batchTimeout time.Duration, rl logger.Infof("Starting solo with queueSize=%d, batchSize=%d batchTimeout=%v and ledger=%T", queueSize, batchSize, batchTimeout, rl) s := &server{ bs: newBroadcastServer(queueSize, batchSize, batchTimeout, rl, filters, configManager), - ds: newDeliverServer(rl, maxWindowSize), + ds: NewDeliverServer(rl, maxWindowSize), } ab.RegisterAtomicBroadcastServer(grpcServer, s) return s @@ -58,5 +58,5 @@ func (s *server) Broadcast(srv ab.AtomicBroadcast_BroadcastServer) error { // Deliver sends a stream of blocks to a client after ordering func (s *server) Deliver(srv ab.AtomicBroadcast_DeliverServer) error { logger.Debugf("Starting new Deliver loop") - return s.ds.handleDeliver(srv) + return s.ds.HandleDeliver(srv) }