-
Notifications
You must be signed in to change notification settings - Fork 189
/
controller.go
46 lines (37 loc) · 1.11 KB
/
controller.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 vm
import (
"context"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type ControllerAdmissionMsg interface {
sdk.Msg
CheckAdmissibility(sdk.Context, interface{}) error
// GetInboundMsgCount returns the number of Swingset messages which will
// be added to the inboundQueue.
GetInboundMsgCount() int32
// IsHighPriority returns whether the message should be considered for
// high priority processing, including bypass of some inbound checks
// and queueing on higher priority queues.
IsHighPriority(sdk.Context, interface{}) (bool, error)
}
type PortHandler interface {
Receive(context.Context, string) (string, error)
}
type protectedPortHandler struct {
inner PortHandler
}
func (h protectedPortHandler) Receive(ctx context.Context, str string) (ret string, err error) {
defer func() {
if r := recover(); r != nil {
// Propagate just the string, not the error stack or we will invite
// nondeterminism.
err = fmt.Errorf("panic: %s", r)
}
}()
ret, err = h.inner.Receive(ctx, str)
return
}
func NewProtectedPortHandler(inner PortHandler) PortHandler {
return protectedPortHandler{inner}
}