dione/consensus/validation/payload_validator.go
2021-06-11 14:40:39 +03:00

22 lines
547 B
Go

package validation
import "github.com/Secured-Finance/dione/types"
var validations = map[uint8]map[string]func(*types.DioneTask) error{} // rpcType -> {rpcMethodName -> actual func var}
func RegisterValidation(typ uint8, methods map[string]func(*types.DioneTask) error) {
validations[typ] = methods
}
func GetValidationMethod(typ uint8, methodName string) func(*types.DioneTask) error {
rpcMethods, ok := validations[typ]
if !ok {
return nil
}
actualMethod, ok := rpcMethods[methodName]
if !ok {
return nil
}
return actualMethod
}