Skip to content

Commit

Permalink
go/worker/keymanager/p2p: Explicitly configure timeout for CallEnclave
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Feb 2, 2024
1 parent f72d593 commit d43352d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion go/worker/keymanager/p2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ type client struct {

func (c *client) CallEnclave(ctx context.Context, request *CallEnclaveRequest, peers []core.PeerID) (*CallEnclaveResponse, rpc.PeerFeedback, error) {
var rsp CallEnclaveResponse
pf, err := c.rc.CallOne(ctx, c.mgr.GetBestPeers(rpc.WithLimitPeers(peers)), MethodCallEnclave, request, &rsp)
pf, err := c.rc.CallOne(ctx, c.mgr.GetBestPeers(rpc.WithLimitPeers(peers)), MethodCallEnclave, request, &rsp,
rpc.WithMaxPeerResponseTime(MethodCallEnclaveTimeout),
)
if err != nil {
return nil, nil, err
}
Expand Down
9 changes: 7 additions & 2 deletions go/worker/keymanager/p2p/protocol.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package p2p

import (
"time"

"github.com/libp2p/go-libp2p/core"

"github.com/oasisprotocol/oasis-core/go/common/node"
Expand All @@ -16,8 +18,11 @@ const KeyManagerProtocolID = "keymanager"
// KeyManagerProtocolVersion is the supported version of the keymanager protocol.
var KeyManagerProtocolVersion = version.Version{Major: 2, Minor: 0, Patch: 0}

// MethodCallEnclave is the name of the CallEnclave method.
const MethodCallEnclave = "CallEnclave"
// Constants related to the CallEnclave method.
const (
MethodCallEnclave = "CallEnclave"
MethodCallEnclaveTimeout = 3 * time.Second
)

// CallEnclaveRequest is a CallEnclave request.
type CallEnclaveRequest struct {
Expand Down

0 comments on commit d43352d

Please sign in to comment.