-
Notifications
You must be signed in to change notification settings - Fork 12
/
committer.go
36 lines (29 loc) · 919 Bytes
/
committer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package golang
import (
"context"
"github.com/davidkhala/goutils"
"github.com/hyperledger/fabric-protos-go-apiv2/common"
"github.com/hyperledger/fabric-protos-go-apiv2/orderer"
"google.golang.org/grpc"
)
type Committer struct {
orderer.AtomicBroadcastClient
orderer.AtomicBroadcast_BroadcastClient // not intrinsic
}
func CommitterFrom(connect *grpc.ClientConn) orderer.AtomicBroadcastClient {
return orderer.NewAtomicBroadcastClient(connect)
}
func (committer *Committer) Setup(ctx context.Context) (err error) {
if ctx == nil {
ctx = goutils.GetGoContext()
}
committer.AtomicBroadcast_BroadcastClient, err = committer.AtomicBroadcastClient.Broadcast(ctx)
return
}
func (committer *Committer) SendRecv(envelope *common.Envelope) (*orderer.BroadcastResponse, error) {
err := committer.Send(envelope)
if err != nil {
return nil, err
}
return committer.AtomicBroadcast_BroadcastClient.Recv()
}