Skip to content

Commit

Permalink
Make DeliverServer public
Browse files Browse the repository at this point in the history
Change-Id: Icff12ae69dc7edfb7f899487188dfbcca82d66a5
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Nov 3, 2016
1 parent e6d2c9b commit a52f2f3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions orderer/solo/deliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ 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()

}

type deliverer struct {
ds *deliverServer
ds *DeliverServer
srv ab.AtomicBroadcast_DeliverServer
cursor rawledger.Iterator
nextBlockNumber uint64
Expand All @@ -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,
Expand Down
24 changes: 12 additions & 12 deletions orderer/solo/deliver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}

Expand Down Expand Up @@ -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}}}

Expand All @@ -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)}}}

Expand All @@ -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)}}}

Expand Down Expand Up @@ -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}}}

Expand All @@ -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}}}

Expand Down
6 changes: 3 additions & 3 deletions orderer/solo/solo.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func init() {

type server struct {
bs *broadcastServer
ds *deliverServer
ds *DeliverServer
}

// New creates a ab.AtomicBroadcastServer based on the solo orderer implementation
func New(queueSize, batchSize, maxWindowSize int, batchTimeout time.Duration, rl rawledger.ReadWriter, grpcServer *grpc.Server, filters *broadcastfilter.RuleSet, configManager configtx.Manager) ab.AtomicBroadcastServer {
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
Expand All @@ -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)
}

0 comments on commit a52f2f3

Please sign in to comment.