Skip to content

Commit

Permalink
use internally tagged enums for fragment pool errors descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed May 4, 2021
1 parent c951be5 commit 76907e8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 46 deletions.
37 changes: 14 additions & 23 deletions doc/api/v0.yaml
Expand Up @@ -637,30 +637,21 @@ paths:
description: The ID of a rejected fragment
type: string
format: '[0-9a-f]+'
pool_number:
description: The number of the pool that caused this error
type: integer
reason:
oneOf:
- description: |
* `FragmentAlreadyInLog` -- this fragment was already processed by this node.
* `FragmentInvalid` -- this fragment failed validation.
* `PreviousFragmentInvalid` -- one of the previous fragments was rejected and `fail_fast` is enabled.
type: string
enum:
- FragmentAlreadyInLog
- FragmentInvalid
- PreviousFragmentInvalid
- description: One of the pools rejected this fragment due to reaching the capacity limit
type: object
required:
- PoolOverflow
properties:
PoolOverflow:
type: object
required:
- pool_number
properties:
pool_number:
description: The number of the pool (corresponding to the leader number) that triggered this error
type: integer
description: |
* `FragmentAlreadyInLog` -- this fragment was already processed by this node.
* `FragmentInvalid` -- this fragment failed validation.
* `PreviousFragmentInvalid` -- one of the previous fragments was rejected and `fail_fast` is enabled.
* `PoolOverflow` -- One of the pools rejected this fragment due to reaching the capacity limit.
type: string
enum:
- FragmentAlreadyInLog
- FragmentInvalid
- PreviousFragmentInvalid
- PoolOverflow
'400':
description: Message is malformed

Expand Down
37 changes: 14 additions & 23 deletions doc/api/v1.yaml
Expand Up @@ -65,30 +65,21 @@ paths:
description: The ID of a rejected fragment
type: string
format: '[0-9a-f]+'
pool_number:
description: The number of the pool that caused this error
type: integer
reason:
oneOf:
- description: |
* `FragmentAlreadyInLog` -- this fragment was already processed by this node.
* `FragmentInvalid` -- this fragment failed validation.
* `PreviousFragmentInvalid` -- one of the previous fragments was rejected and `fail_fast` is enabled.
type: string
enum:
- FragmentAlreadyInLog
- FragmentInvalid
- PreviousFragmentInvalid
- description: One of the pools rejected this fragment due to reaching the capacity limit
type: object
required:
- PoolOverflow
properties:
PoolOverflow:
type: object
required:
- pool_number
properties:
pool_number:
description: The number of the pool (corresponding to the leader number) that triggered this error
type: integer
description: |
* `FragmentAlreadyInLog` -- this fragment was already processed by this node.
* `FragmentInvalid` -- this fragment failed validation.
* `PreviousFragmentInvalid` -- one of the previous fragments was rejected and `fail_fast` is enabled.
* `PoolOverflow` -- One of the pools rejected this fragment due to reaching the capacity limit.
type: string
enum:
- FragmentAlreadyInLog
- FragmentInvalid
- PreviousFragmentInvalid
- PoolOverflow
'400':
description: One of messages is malformed

Expand Down
Expand Up @@ -7,6 +7,7 @@ use serde_with::{serde_as, DisplayFromStr};
/// them to mempool. If a fragment ended up being included to mempool, it will be listed in
/// fragment logs and all further errors would be listed in fragment logs as well.
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum FragmentRejectionReason {
FragmentAlreadyInLog,
FragmentInvalid,
Expand All @@ -21,6 +22,7 @@ pub enum FragmentRejectionReason {
pub struct RejectedFragmentInfo {
#[serde_as(as = "DisplayFromStr")]
pub id: FragmentId,
#[serde(flatten)]
pub reason: FragmentRejectionReason,
}

Expand Down

0 comments on commit 76907e8

Please sign in to comment.