-
Notifications
You must be signed in to change notification settings - Fork 6
/
chaincode_event_service.go
56 lines (47 loc) · 1.83 KB
/
chaincode_event_service.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package gateway
import (
"context"
"github.com/hyperledger-labs/cckit/sdk"
)
type (
ChaincodeEventService struct {
EventDelivery sdk.EventDelivery
}
// ChaincodeEventsServer gateway/chaincode.go needs access to grpc stream
ChaincodeEventsServer = chaincodeServiceEventsStreamServer
)
var _ ChaincodeEventsServiceServer = &ChaincodeEventService{}
// ServiceDef returns service definition
func (ce *ChaincodeEventService) ServiceDef() ServiceDef {
return ServiceDef{
Desc: &_ChaincodeEventsService_serviceDesc,
Service: ce,
HandlerFromEndpointRegister: RegisterChaincodeEventsServiceHandlerFromEndpoint,
}
}
func (ce *ChaincodeEventService) Events(ctx context.Context, req *ChaincodeEventsRequest) (*ChaincodeEvents, error) {
return NewChaincodeInstanceEventService(ce.EventDelivery, req.Locator.Channel, req.Locator.Chaincode).
Events(ctx, &ChaincodeInstanceEventsRequest{
FromBlock: req.FromBlock,
ToBlock: req.ToBlock,
EventName: req.EventName,
Limit: req.Limit,
})
}
func (ce *ChaincodeEventService) EventsStream(req *ChaincodeEventsStreamRequest, stream ChaincodeEventsService_EventsStreamServer) error {
return NewChaincodeInstanceEventService(ce.EventDelivery, req.Locator.Channel, req.Locator.Chaincode).
EventsStream(&ChaincodeInstanceEventsStreamRequest{
FromBlock: req.FromBlock,
ToBlock: req.ToBlock,
EventName: req.EventName,
}, stream)
}
func (ce *ChaincodeEventService) EventsChan(
ctx context.Context, req *ChaincodeEventsStreamRequest) (_ chan *ChaincodeEvent, closer func() error, _ error) {
return NewChaincodeInstanceEventService(ce.EventDelivery, req.Locator.Channel, req.Locator.Chaincode).
EventsChan(ctx, &ChaincodeInstanceEventsStreamRequest{
FromBlock: req.FromBlock,
ToBlock: req.ToBlock,
EventName: req.EventName,
})
}