dione/consensus/validation/payload_validator.go

22 lines
547 B
Go
Raw Normal View History

2020-12-02 21:18:47 +00:00
package validation
import "github.com/Secured-Finance/dione/types"
2020-12-02 21:18:47 +00:00
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) {
2020-12-02 21:18:47 +00:00
validations[typ] = methods
}
func GetValidationMethod(typ uint8, methodName string) func(*types.DioneTask) error {
2020-12-02 21:18:47 +00:00
rpcMethods, ok := validations[typ]
if !ok {
return nil
}
actualMethod, ok := rpcMethods[methodName]
if !ok {
return nil
}
return actualMethod
}