-
Notifications
You must be signed in to change notification settings - Fork 12
/
committer.go
37 lines (30 loc) · 959 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
37
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
context.Context
}
func CommitterFrom(connect *grpc.ClientConn) orderer.AtomicBroadcastClient {
return orderer.NewAtomicBroadcastClient(connect)
}
func (committer *Committer) Setup() (err error) {
if committer.Context == nil {
committer.Context = goutils.GetGoContext()
}
committer.AtomicBroadcast_BroadcastClient, err = committer.AtomicBroadcastClient.Broadcast(committer.Context)
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()
}