-
Notifications
You must be signed in to change notification settings - Fork 107
/
protocol.go
51 lines (41 loc) · 1.5 KB
/
protocol.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
package p2p
import (
"github.com/libp2p/go-libp2p/core"
"github.com/oasisprotocol/oasis-core/go/common/node"
"github.com/oasisprotocol/oasis-core/go/common/version"
"github.com/oasisprotocol/oasis-core/go/p2p/peermgmt"
"github.com/oasisprotocol/oasis-core/go/p2p/protocol"
enclaverpc "github.com/oasisprotocol/oasis-core/go/runtime/enclaverpc/api"
)
// KeyManagerProtocolID is a unique protocol identifier for the keymanager protocol.
const KeyManagerProtocolID = "keymanager"
// KeyManagerProtocolVersion is the supported version of the keymanager protocol.
var KeyManagerProtocolVersion = version.Version{Major: 2, Minor: 0, Patch: 0}
// Constants related to the GetDiff method.
const (
MethodCallEnclave = "CallEnclave"
MaxCallEnclaveRetries = 15
)
// CallEnclaveRequest is a CallEnclave request.
type CallEnclaveRequest struct {
Data []byte `json:"data"`
Kind enclaverpc.Kind `json:"kind,omitempty"`
}
// CallEnclaveResponse is a response to a CallEnclave request.
type CallEnclaveResponse struct {
Data []byte `json:"data"`
}
func init() {
peermgmt.RegisterNodeHandler(&peermgmt.NodeHandlerBundle{
ProtocolsFn: func(n *node.Node, chainContext string) []core.ProtocolID {
if !n.HasRoles(node.RoleKeyManager) {
return []core.ProtocolID{}
}
protocols := make([]core.ProtocolID, len(n.Runtimes))
for i, rt := range n.Runtimes {
protocols[i] = protocol.NewRuntimeProtocolID(chainContext, rt.ID, KeyManagerProtocolID, KeyManagerProtocolVersion)
}
return protocols
},
})
}