Skip to content

Commit d41e2a6

Browse files
Introduce P2PCommunicationType constants
Both, the libp2p and websocket implementations now are define a constant to help identify the selected implementation via FSC configuration. These constants were previously defined within the NWO space; however as addressing #434, NWO now consumes these constants from the corresponding p2p comm packages. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
1 parent 1c715d4 commit d41e2a6

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

integration/nwo/fsc/topology.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ package fsc
99
import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/node"
1111
node2 "github.com/hyperledger-labs/fabric-smart-client/pkg/node"
12+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/comm/host/libp2p"
13+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/comm/host/rest"
1214
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/tracing"
1315
)
1416

@@ -25,8 +27,8 @@ type Logging struct {
2527
type P2PCommunicationType = string
2628

2729
const (
28-
LibP2P P2PCommunicationType = "libp2p"
29-
WebSocket P2PCommunicationType = "websocket"
30+
LibP2P P2PCommunicationType = libp2p.P2PCommunicationType
31+
WebSocket P2PCommunicationType = rest.P2PCommunicationType
3032
)
3133

3234
type Topology struct {

platform/view/services/comm/host/libp2p/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import (
1717
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
1818
)
1919

20+
// P2PCommunicationType is a string identifier for the libp2p implementation of the p2p comm stack.
21+
const P2PCommunicationType = "libp2p"
22+
2023
type libp2pConfig interface {
2124
PrivateKeyPath() string
2225
Bootstrap() bool

platform/view/services/comm/host/rest/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/id"
1515
)
1616

17+
// P2PCommunicationType is a string identifier for the websocket implementation of the p2p comm stack.
18+
const P2PCommunicationType = "websocket"
19+
1720
type pkiExtractor interface {
1821
ExtractPKI(id []byte) []byte
1922
}

platform/view/services/comm/provider/provider.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package provider
99
import (
1010
"strings"
1111

12-
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
1312
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
1413
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/comm"
1514
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/comm/host"
@@ -32,7 +31,7 @@ func NewHostProvider(
3231
return nil, err
3332
}
3433

35-
if p2pCommType := config.GetString("fsc.p2p.type"); strings.EqualFold(p2pCommType, fsc.WebSocket) {
34+
if p2pCommType := config.GetString("fsc.p2p.type"); strings.EqualFold(p2pCommType, rest.P2PCommunicationType) {
3635
return NewWebSocketHostProvider(config, endpointService, tracerProvider, metricsProvider)
3736
} else {
3837
return NewLibP2PHostProvider(config, endpointService, metricsProvider), nil

0 commit comments

Comments
 (0)