diff options
Diffstat (limited to 'components/wisp_relay/relay_validator.h')
| -rw-r--r-- | components/wisp_relay/relay_validator.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/components/wisp_relay/relay_validator.h b/components/wisp_relay/relay_validator.h new file mode 100644 index 0000000..c07308f --- /dev/null +++ b/components/wisp_relay/relay_validator.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | #ifndef RELAY_VALIDATOR_H | ||
| 2 | #define RELAY_VALIDATOR_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <stddef.h> | ||
| 7 | |||
| 8 | typedef enum { | ||
| 9 | VALIDATION_OK = 0, | ||
| 10 | VALIDATION_ERR_SCHEMA, | ||
| 11 | VALIDATION_ERR_ID, | ||
| 12 | VALIDATION_ERR_SIG, | ||
| 13 | VALIDATION_ERR_EXPIRED, | ||
| 14 | VALIDATION_ERR_FUTURE, | ||
| 15 | VALIDATION_ERR_DUPLICATE, | ||
| 16 | VALIDATION_ERR_POW, | ||
| 17 | VALIDATION_ERR_BLOCKED, | ||
| 18 | VALIDATION_ERR_TOO_OLD, | ||
| 19 | } validation_result_t; | ||
| 20 | |||
| 21 | typedef struct { | ||
| 22 | uint32_t max_event_age_sec; | ||
| 23 | int64_t max_future_sec; | ||
| 24 | uint8_t min_pow_difficulty; | ||
| 25 | bool check_duplicates; | ||
| 26 | } validator_config_t; | ||
| 27 | |||
| 28 | typedef struct relay_event relay_event_t; | ||
| 29 | typedef struct storage_engine storage_engine_t; | ||
| 30 | |||
| 31 | validation_result_t relay_validator_check(const uint8_t *id, | ||
| 32 | const uint8_t *pubkey, | ||
| 33 | uint64_t created_at, | ||
| 34 | int kind, | ||
| 35 | const char *content, | ||
| 36 | size_t content_len, | ||
| 37 | const char *tags_json, | ||
| 38 | const uint8_t *sig, | ||
| 39 | const validator_config_t *config); | ||
| 40 | |||
| 41 | bool relay_validator_verify_event(const char *event_json, size_t event_len); | ||
| 42 | |||
| 43 | const char *relay_validator_result_string(validation_result_t result); | ||
| 44 | |||
| 45 | #endif | ||