dione/consensus/validation/payload_validation_manager.go
2020-12-03 01:18:47 +04:00

20 lines
468 B
Go

package validation
var validations = map[uint8]map[string]func([]byte) error{} // rpcType -> {rpcMethodName -> actual func var}
func RegisterValidation(typ uint8, methods map[string]func([]byte) error) {
validations[typ] = methods
}
func GetValidationMethod(typ uint8, methodName string) func([]byte) error {
rpcMethods, ok := validations[typ]
if !ok {
return nil
}
actualMethod, ok := rpcMethods[methodName]
if !ok {
return nil
}
return actualMethod
}