/
mutation.go
46 lines (43 loc) · 1023 Bytes
/
mutation.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
package resolvers
import (
"context"
appconfig "github.com/kfsoftware/hlf-channel-manager/config"
"github.com/kfsoftware/hlf-channel-manager/gql/models"
"github.com/kfsoftware/hlf-channel-manager/store/channel"
"gopkg.in/yaml.v3"
)
func (r *mutationResolver) SyncChannel(
ctx context.Context,
channelConfigStr string,
saveOrderer bool,
saveApplication bool,
joinOrderers bool,
joinPeers bool,
) (*models.SyncChannelResponse, error) {
channelConfig := appconfig.ChannelConfig{}
err := yaml.Unmarshal([]byte(channelConfigStr), &channelConfig)
if err != nil {
return nil, err
}
res, err := channel.SyncChannel(
ctx,
channelConfig,
r.DCS,
r.FabricSDK,
r.ConfigBackend,
saveOrderer,
saveApplication,
joinOrderers,
joinPeers,
)
if err != nil {
return nil, err
}
return &models.SyncChannelResponse{
Success: true,
ApplicationTxID: res.ApplicationTxId,
OrdererTxID: res.OrdererTxId,
OrderersJoined: res.OrderersJoined,
PeersJoined: res.PeersJoined,
}, nil
}