Skip to content

Commit 492f2ad

Browse files
author
Jason Yellick
committed
Move ab Status codes to common
In order to have consistent error reporting across the fabric, it has been decided to use standard HTTP status codes. These were defined in the orderer ab.proto, but have wider applicability. This changeset removes the Status message from ab.proto and moves it to common.proto. Change-Id: I511bcdd0442e9b06daba678763c87f32478377f4 Signed-off-by: Jason Yellick <[email protected]>
1 parent bc358a5 commit 492f2ad

File tree

25 files changed

+246
-246
lines changed

25 files changed

+246
-246
lines changed

bddtests/common/common_pb2.py

+54-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bddtests/orderer/ab_pb2.py

+14-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/committer/noopssinglechain/committer.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/hyperledger/fabric/core/chaincode"
2828
"github.com/hyperledger/fabric/core/committer"
2929
"github.com/hyperledger/fabric/core/ledger/kvledger"
30+
cb "github.com/hyperledger/fabric/protos/common"
3031
ab "github.com/hyperledger/fabric/protos/orderer"
3132
putils "github.com/hyperledger/fabric/protos/utils"
3233
"golang.org/x/net/context"
@@ -127,7 +128,7 @@ func (r *deliverClient) readUntilClose() {
127128

128129
switch t := msg.Type.(type) {
129130
case *ab.DeliverResponse_Error:
130-
if t.Error == ab.Status_SUCCESS {
131+
if t.Error == cb.Status_SUCCESS {
131132
fmt.Println("ERROR! Received success in error field")
132133
return
133134
}

orderer/kafka/broadcast.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (b *broadcasterImpl) recvRequests(stream ab.AtomicBroadcast_BroadcastServer
145145
}
146146

147147
b.batchChan <- msg
148-
reply.Status = ab.Status_SUCCESS // TODO This shouldn't always be a success
148+
reply.Status = cb.Status_SUCCESS // TODO This shouldn't always be a success
149149

150150
if err := stream.Send(reply); err != nil {
151151
logger.Info("Cannot send broadcast reply to client")

orderer/kafka/broadcast_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/golang/protobuf/proto"
2626
cb "github.com/hyperledger/fabric/protos/common"
27-
ab "github.com/hyperledger/fabric/protos/orderer"
2827
)
2928

3029
func TestBroadcastInit(t *testing.T) {
@@ -81,7 +80,7 @@ func TestBroadcastResponse(t *testing.T) {
8180
for {
8281
select {
8382
case reply := <-mbs.outgoing:
84-
if reply.Status != ab.Status_SUCCESS {
83+
if reply.Status != cb.Status_SUCCESS {
8584
t.Fatal("Client should have received a SUCCESS reply")
8685
}
8786
return

orderer/kafka/client_deliver.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ func (cd *clientDelivererImpl) sendBlocks(stream ab.AtomicBroadcast_DeliverServe
105105
err = cd.processACK(t)
106106
}
107107
if err != nil {
108-
var errorStatus ab.Status
108+
var errorStatus cb.Status
109109
// TODO Will need to flesh this out into
110110
// a proper error handling system eventually.
111111
switch err.Error() {
112112
case seekOutOfRangeError:
113-
errorStatus = ab.Status_NOT_FOUND
113+
errorStatus = cb.Status_NOT_FOUND
114114
case ackOutOfRangeError, windowOutOfRangeError:
115-
errorStatus = ab.Status_BAD_REQUEST
115+
errorStatus = cb.Status_BAD_REQUEST
116116
default:
117-
errorStatus = ab.Status_SERVICE_UNAVAILABLE
117+
errorStatus = cb.Status_SERVICE_UNAVAILABLE
118118
}
119119
reply = new(ab.DeliverResponse)
120120
reply.Type = &ab.DeliverResponse_Error{Error: errorStatus}

orderer/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func retrieveConfiguration(rl rawledger.Reader) *cb.ConfigurationEnvelope {
9494
select {
9595
case <-it.ReadyChan():
9696
block, status := it.Next()
97-
if status != ab.Status_SUCCESS {
97+
if status != cb.Status_SUCCESS {
9898
panic(fmt.Errorf("Error parsing blockchain at startup: %v", status))
9999
}
100100
// ConfigTxs should always be by themselves

orderer/rawledger/blackbox_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func getBlock(number uint64, li ReadWriter) *cb.Block {
4343
select {
4444
case <-i.ReadyChan():
4545
block, status := i.Next()
46-
if status != ab.Status_SUCCESS {
46+
if status != cb.Status_SUCCESS {
4747
return nil
4848
}
4949
return block
@@ -155,7 +155,7 @@ func testRetrieval(lf ledgerFactory, t *testing.T) {
155155
t.Fatalf("Should be ready for block read")
156156
}
157157
block, status := it.Next()
158-
if status != ab.Status_SUCCESS {
158+
if status != cb.Status_SUCCESS {
159159
t.Fatalf("Expected to successfully read the genesis block")
160160
}
161161
if block.Header.Number != 0 {
@@ -168,7 +168,7 @@ func testRetrieval(lf ledgerFactory, t *testing.T) {
168168
t.Fatalf("Should still be ready for block read")
169169
}
170170
block, status = it.Next()
171-
if status != ab.Status_SUCCESS {
171+
if status != cb.Status_SUCCESS {
172172
t.Fatalf("Expected to successfully read the second block")
173173
}
174174
if block.Header.Number != 1 {
@@ -199,7 +199,7 @@ func testBlockedRetrieval(lf ledgerFactory, t *testing.T) {
199199
t.Fatalf("Should now be ready for block read")
200200
}
201201
block, status := it.Next()
202-
if status != ab.Status_SUCCESS {
202+
if status != cb.Status_SUCCESS {
203203
t.Fatalf("Expected to successfully read the second block")
204204
}
205205
if block.Header.Number != 1 {

orderer/rawledger/fileledger/fileledger.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,16 @@ func (fl *fileLedger) Iterator(startType ab.SeekInfo_StartType, specified uint64
200200
}
201201

202202
// Next blocks until there is a new block available, or returns an error if the next block is no longer retrievable
203-
func (cu *cursor) Next() (*cb.Block, ab.Status) {
203+
func (cu *cursor) Next() (*cb.Block, cb.Status) {
204204
// This only loops once, as signal reading indicates the new block has been written
205205
for {
206206
block, found := cu.fl.readBlock(cu.blockNumber)
207207
if found {
208208
if block == nil {
209-
return nil, ab.Status_SERVICE_UNAVAILABLE
209+
return nil, cb.Status_SERVICE_UNAVAILABLE
210210
}
211211
cu.blockNumber++
212-
return block, ab.Status_SUCCESS
212+
return block, cb.Status_SUCCESS
213213
}
214214
<-cu.fl.signal
215215
}

orderer/rawledger/fileledger/fileledger_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestRetrieval(t *testing.T) {
122122
t.Fatalf("Should be ready for block read")
123123
}
124124
block, status := it.Next()
125-
if status != ab.Status_SUCCESS {
125+
if status != cb.Status_SUCCESS {
126126
t.Fatalf("Expected to successfully read the genesis block")
127127
}
128128
if block.Header.Number != 0 {
@@ -135,7 +135,7 @@ func TestRetrieval(t *testing.T) {
135135
t.Fatalf("Should still be ready for block read")
136136
}
137137
block, status = it.Next()
138-
if status != ab.Status_SUCCESS {
138+
if status != cb.Status_SUCCESS {
139139
t.Fatalf("Expected to successfully read the second block")
140140
}
141141
if block.Header.Number != 1 {
@@ -163,7 +163,7 @@ func TestBlockedRetrieval(t *testing.T) {
163163
t.Fatalf("Should now be ready for block read")
164164
}
165165
block, status := it.Next()
166-
if status != ab.Status_SUCCESS {
166+
if status != cb.Status_SUCCESS {
167167
t.Fatalf("Expected to successfully read the second block")
168168
}
169169
if block.Header.Number != 1 {

0 commit comments

Comments
 (0)