Skip to content

Commit e5be010

Browse files
committed
go/worker: Use ProtocolID helper to avoid duplication
1 parent 5c20629 commit e5be010

File tree

12 files changed

+12
-18
lines changed

12 files changed

+12
-18
lines changed

go/worker/common/p2p/txsync/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/oasisprotocol/oasis-core/go/common"
77
"github.com/oasisprotocol/oasis-core/go/common/crypto/hash"
8-
"github.com/oasisprotocol/oasis-core/go/p2p/protocol"
98
"github.com/oasisprotocol/oasis-core/go/p2p/rpc"
109
)
1110

@@ -82,7 +81,7 @@ func (c *client) GetTxs(ctx context.Context, request *GetTxsRequest) (*GetTxsRes
8281

8382
// NewClient creates a new transaction sync protocol client.
8483
func NewClient(p2p rpc.P2P, chainContext string, runtimeID common.Namespace) Client {
85-
pid := protocol.NewRuntimeProtocolID(chainContext, runtimeID, TxSyncProtocolID, TxSyncProtocolVersion)
84+
pid := ProtocolID(chainContext, runtimeID)
8685
mgr := rpc.NewPeerManager(p2p, pid)
8786
rc := rpc.NewClient(p2p.Host(), pid)
8887
rc.RegisterListener(mgr)

go/worker/common/p2p/txsync/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func init() {
4747

4848
protocols := make([]core.ProtocolID, len(n.Runtimes))
4949
for i, rt := range n.Runtimes {
50-
protocols[i] = protocol.NewRuntimeProtocolID(chainContext, rt.ID, TxSyncProtocolID, TxSyncProtocolVersion)
50+
protocols[i] = ProtocolID(chainContext, rt.ID)
5151
}
5252

5353
return protocols

go/worker/keymanager/p2p/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/oasisprotocol/oasis-core/go/common"
99
p2p "github.com/oasisprotocol/oasis-core/go/p2p/api"
10-
"github.com/oasisprotocol/oasis-core/go/p2p/protocol"
1110
"github.com/oasisprotocol/oasis-core/go/p2p/rpc"
1211
)
1312

@@ -46,7 +45,7 @@ func (c *client) CallEnclave(ctx context.Context, request *CallEnclaveRequest, p
4645

4746
// NewClient creates a new keymanager protocol client.
4847
func NewClient(p2p p2p.Service, chainContext string, keymanagerID common.Namespace) Client {
49-
pid := protocol.NewRuntimeProtocolID(chainContext, keymanagerID, KeyManagerProtocolID, KeyManagerProtocolVersion)
48+
pid := ProtocolID(chainContext, keymanagerID)
5049
mgr := rpc.NewPeerManager(p2p, pid)
5150
rc := rpc.NewClient(p2p.Host(), pid)
5251
rc.RegisterListener(mgr)

go/worker/keymanager/p2p/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func init() {
5050

5151
protocols := make([]core.ProtocolID, len(n.Runtimes))
5252
for i, rt := range n.Runtimes {
53-
protocols[i] = protocol.NewRuntimeProtocolID(chainContext, rt.ID, KeyManagerProtocolID, KeyManagerProtocolVersion)
53+
protocols[i] = ProtocolID(chainContext, rt.ID)
5454
}
5555

5656
return protocols

go/worker/storage/p2p/checkpointsync/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/oasisprotocol/oasis-core/go/common"
99
"github.com/oasisprotocol/oasis-core/go/common/crypto/hash"
10-
"github.com/oasisprotocol/oasis-core/go/p2p/protocol"
1110
"github.com/oasisprotocol/oasis-core/go/p2p/rpc"
1211
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/checkpoint"
1312
)
@@ -111,7 +110,7 @@ func (c *client) GetCheckpointChunk(
111110
//
112111
// Moreover, it ensures underlying p2p service starts tracking protocol peers.
113112
func NewClient(p2p rpc.P2P, chainContext string, runtimeID common.Namespace) Client {
114-
pid := protocol.NewRuntimeProtocolID(chainContext, runtimeID, CheckpointSyncProtocolID, CheckpointSyncProtocolVersion)
113+
pid := ProtocolID(chainContext, runtimeID)
115114
rc := rpc.NewClient(p2p.Host(), pid)
116115
mgr := rpc.NewPeerManager(p2p, pid)
117116
rc.RegisterListener(mgr)

go/worker/storage/p2p/checkpointsync/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func init() {
7171

7272
protocols := make([]core.ProtocolID, len(n.Runtimes))
7373
for i, rt := range n.Runtimes {
74-
protocols[i] = protocol.NewRuntimeProtocolID(chainContext, rt.ID, CheckpointSyncProtocolID, CheckpointSyncProtocolVersion)
74+
protocols[i] = ProtocolID(chainContext, rt.ID)
7575
}
7676

7777
return protocols

go/worker/storage/p2p/diffsync/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/oasisprotocol/oasis-core/go/common"
7-
"github.com/oasisprotocol/oasis-core/go/p2p/protocol"
87
"github.com/oasisprotocol/oasis-core/go/p2p/rpc"
98
)
109

@@ -44,7 +43,7 @@ func (c *client) GetDiff(ctx context.Context, request *GetDiffRequest) (*GetDiff
4443
//
4544
// Moreover, it ensures underlying p2p service starts tracking protocol peers.
4645
func NewClient(p2p rpc.P2P, chainContext string, runtimeID common.Namespace) Client {
47-
pid := protocol.NewRuntimeProtocolID(chainContext, runtimeID, DiffSyncProtocolID, DiffSyncProtocolVersion)
46+
pid := ProtocolID(chainContext, runtimeID)
4847
rc := rpc.NewClient(p2p.Host(), pid)
4948
mgr := rpc.NewPeerManager(p2p, pid)
5049
rc.RegisterListener(mgr)

go/worker/storage/p2p/diffsync/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func init() {
5252

5353
protocols := make([]core.ProtocolID, len(n.Runtimes))
5454
for i, rt := range n.Runtimes {
55-
protocols[i] = protocol.NewRuntimeProtocolID(chainContext, rt.ID, DiffSyncProtocolID, DiffSyncProtocolVersion)
55+
protocols[i] = ProtocolID(chainContext, rt.ID)
5656
}
5757

5858
return protocols

go/worker/storage/p2p/pub/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/oasisprotocol/oasis-core/go/common"
7-
"github.com/oasisprotocol/oasis-core/go/p2p/protocol"
87
"github.com/oasisprotocol/oasis-core/go/p2p/rpc"
98
)
109

@@ -64,7 +63,7 @@ func (c *client) Iterate(ctx context.Context, request *IterateRequest) (*ProofRe
6463

6564
// NewClient creates a new storage pub protocol client.
6665
func NewClient(p2p rpc.P2P, chainContext string, runtimeID common.Namespace) Client {
67-
pid := protocol.NewRuntimeProtocolID(chainContext, runtimeID, StoragePubProtocolID, StoragePubProtocolVersion)
66+
pid := ProtocolID(chainContext, runtimeID)
6867
mgr := rpc.NewPeerManager(p2p, pid)
6968
rc := rpc.NewClient(p2p.Host(), pid)
7069
rc.RegisterListener(mgr)

go/worker/storage/p2p/pub/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func init() {
5858

5959
protocols := make([]core.ProtocolID, len(n.Runtimes))
6060
for i, rt := range n.Runtimes {
61-
protocols[i] = protocol.NewRuntimeProtocolID(chainContext, rt.ID, StoragePubProtocolID, StoragePubProtocolVersion)
61+
protocols[i] = ProtocolID(chainContext, rt.ID)
6262
}
6363

6464
return protocols

0 commit comments

Comments
 (0)