Skip to content

Commit

Permalink
Merge "[FAB-13783] incorrect values in block_fill_duration"
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristidis authored and Gerrit Code Review committed Jan 30, 2019
2 parents d8e4dfc + 32d1ac4 commit 8fed497
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion orderer/common/blockcutter/blockcutter.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ func (r *receiver) Ordered(msg *cb.Envelope) (messageBatches [][]*cb.Envelope, p

// Cut returns the current batch and starts a new one
func (r *receiver) Cut() []*cb.Envelope {
r.Metrics.BlockFillDuration.With("channel", r.ChannelID).Observe(time.Since(r.PendingBatchStartTime).Seconds())
if r.pendingBatch != nil {
r.Metrics.BlockFillDuration.With("channel", r.ChannelID).Observe(time.Since(r.PendingBatchStartTime).Seconds())
}
r.PendingBatchStartTime = time.Time{}
batch := r.pendingBatch
r.pendingBatch = nil
Expand Down
8 changes: 8 additions & 0 deletions orderer/common/blockcutter/blockcutter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,12 @@ var _ = Describe("Blockcutter", func() {
})
})
})

Describe("Cut", func() {
It("cuts an empty batch", func() {
batch := bc.Cut()
Expect(batch).To(BeNil())
Expect(fakeBlockFillDuration.ObserveCallCount()).To(Equal(0))
})
})
})

0 comments on commit 8fed497

Please sign in to comment.