-
Notifications
You must be signed in to change notification settings - Fork 4
/
interceptor.go
39 lines (32 loc) · 1.1 KB
/
interceptor.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
package vnlmn
import (
"github.com/insolar/assured-ledger/ledger-core/rms"
"github.com/insolar/assured-ledger/ledger-core/rms/rmsreg"
)
func LRegisterRequestInterceptor(record rmsreg.GoGoSerializable) ([]rmsreg.GoGoSerializable, bool) {
request, ok := record.(*rms.LRegisterRequest)
if !ok {
return nil, false
}
var result []rmsreg.GoGoSerializable
switch request.Flags {
case rms.RegistrationFlags_FastSafe:
result = append(result, &rms.LRegisterResponse{
Flags: rms.RegistrationFlags_Fast,
AnticipatedRef: request.AnticipatedRef,
RegistrarSignature: rms.NewBytes([]byte("dummy")),
})
result = append(result, &rms.LRegisterResponse{
Flags: rms.RegistrationFlags_Safe,
AnticipatedRef: request.AnticipatedRef,
RegistrarSignature: rms.NewBytes([]byte("dummy")),
})
case rms.RegistrationFlags_Safe, rms.RegistrationFlags_Fast:
result = append(result, &rms.LRegisterResponse{
Flags: request.Flags,
AnticipatedRef: request.AnticipatedRef,
RegistrarSignature: rms.NewBytes([]byte("dummy")),
})
}
return result, true
}