dione/consensus/validation/payload_validation_manager.go

20 lines
468 B
Go
Raw Normal View History

2020-12-02 21:18:47 +00:00
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
}