Skip to content

Commit

Permalink
[FAB-8858] Set max message size to be same as fabric
Browse files Browse the repository at this point in the history
Change-Id: Ic3be6df8d338ddf3ec581e75373d5772eec7dad1
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Mar 14, 2018
1 parent ea3acdb commit 267c094
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/fab/comm/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import (

var logger = logging.NewLogger("fabsdk/fab")

const (
// GRPC max message size (same as Fabric)
maxCallRecvMsgSize = 100 * 1024 * 1024
maxCallSendMsgSize = 100 * 1024 * 1024
)

// StreamProvider creates a GRPC stream
type StreamProvider func(conn *grpc.ClientConn) (grpc.ClientStream, error)

Expand Down Expand Up @@ -154,5 +160,8 @@ func newDialOpts(config core.Config, url string, params *params) ([]grpc.DialOpt
dialOpts = append(dialOpts, grpc.WithInsecure())
}

dialOpts = append(dialOpts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxCallRecvMsgSize),
grpc.MaxCallSendMsgSize(maxCallSendMsgSize)))

return dialOpts, nil
}
9 changes: 9 additions & 0 deletions pkg/fab/orderer/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import (

var logger = logging.NewLogger("fabsdk/fab")

const (
// GRPC max message size (same as Fabric)
maxCallRecvMsgSize = 100 * 1024 * 1024
maxCallSendMsgSize = 100 * 1024 * 1024
)

// Orderer allows a client to broadcast a transaction.
type Orderer struct {
config core.Config
Expand Down Expand Up @@ -78,6 +84,9 @@ func New(config core.Config, opts ...Option) (*Orderer, error) {
grpcOpts = append(grpcOpts, grpc.WithInsecure())
}

grpcOpts = append(grpcOpts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxCallRecvMsgSize),
grpc.MaxCallSendMsgSize(maxCallSendMsgSize)))

orderer.dialTimeout = config.TimeoutOrDefault(core.OrdererConnection)
orderer.url = endpoint.ToAddress(orderer.url)
orderer.grpcDialOption = grpcOpts
Expand Down
9 changes: 9 additions & 0 deletions pkg/fab/peer/peerendorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import (
pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
)

const (
// GRPC max message size (same as Fabric)
maxCallRecvMsgSize = 100 * 1024 * 1024
maxCallSendMsgSize = 100 * 1024 * 1024
)

// peerEndorser enables access to a GRPC-based endorser for running transaction proposal simulations
type peerEndorser struct {
grpcDialOption []grpc.DialOption
Expand Down Expand Up @@ -67,6 +73,9 @@ func newPeerEndorser(endorseReq *peerEndorserRequest) (*peerEndorser, error) {
grpcOpts = append(grpcOpts, grpc.WithInsecure())
}

grpcOpts = append(grpcOpts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxCallRecvMsgSize),
grpc.MaxCallSendMsgSize(maxCallSendMsgSize)))

timeout := endorseReq.config.TimeoutOrDefault(core.EndorserConnection)

pc := &peerEndorser{
Expand Down

0 comments on commit 267c094

Please sign in to comment.