Skip to content

Commit

Permalink
Write down JSON-schema for tx monitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Jan 18, 2022
1 parent 97c456f commit 665d192
Show file tree
Hide file tree
Showing 4 changed files with 494 additions and 9 deletions.
351 changes: 351 additions & 0 deletions docs/static/ogmios.wsp.json
Expand Up @@ -7,6 +7,10 @@
, "SubmitTx", "SubmitTxResponse"
, "Acquire", "AcquireResponse"
, "Release","ReleaseResponse"
, "AwaitAcquire", "AwaitAcquireResponse"
, "NextTx", "NextTxResponse"
, "HasTx", "HasTxResponse"
, "SizeAndCapacity", "SizeAndCapacityResponse"
, "Query"
, "QueryResponse[blockHeight]"
, "QueryResponse[chainTip]"
Expand Down Expand Up @@ -472,6 +476,342 @@
}
}

, "AwaitAcquire":
{ "type": "object"
, "description": "Acquire a mempool snapshot. This is blocking until a new (i.e different) snapshot is available."
, "required": [ "type", "version", "servicename", "methodname" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/request" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "AwaitAcquire" ]
}
, "args":
{ "type": "object"
, "additionalProperties": false
}
, "mirror":
{ "description": "An arbitrary JSON value that will be mirrored back in the response."
}
}
}

, "AwaitAcquireResponse":
{ "type": "object"
, "description": "Response to a 'AwaitAcquire' request."
, "required": [ "type", "version", "servicename", "methodname", "result" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/response" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "AwaitAcquire" ]
}
, "result":
{ "type": "object"
, "title": "AcquireSuccess"
, "additionalProperties": false
, "required": [ "AwaitAcquired" ]
, "properties":
{ "AwaitAcquired":
{ "type": "object"
, "additionalProperties": false
, "required": [ "slot" ]
, "properties":
{ "slot": { "$ref": "#/definitions/Slot" }
}
}
}
}
, "reflection":
{ "description": "Any value that was set by a client request in the 'mirror' field."
}
}
}

, "NextTx":
{ "type": "object"
, "description": "Request the next transaction from an acquired snapshot."
, "required": [ "type", "version", "servicename", "methodname" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/request" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "NextTx" ]
}
, "args":
{ "type": "object"
, "additionalProperties": false
}
, "mirror":
{ "description": "An arbitrary JSON value that will be mirrored back in the response."
}
}
}

, "NextTxResponse":
{ "type": "object"
, "description": "Response to a 'NextTx' request."
, "required": [ "type", "version", "servicename", "methodname", "result" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/response" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "NextTx" ]
}
, "result":
{ "oneOf":
[ { "$ref": "#/definitions/TxId" }
, { "type": "null", "title": "null" }
]
}
, "reflection":
{ "description": "Any value that was set by a client request in the 'mirror' field."
}
}
}

, "HasTx":
{ "type": "object"
, "description": "Ask whether a given transaction is present in the acquired mempool snapshot."
, "required": [ "type", "version", "servicename", "methodname" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/request" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "HasTx" ]
}
, "args":
{ "type": "object"
, "additionalProperties": false
, "required": [ "id" ]
, "properties":
{ "id": { "$ref": "#/definitions/TxId" }
}
}
, "mirror":
{ "description": "An arbitrary JSON value that will be mirrored back in the response."
}
}
}

, "HasTxResponse":
{ "type": "object"
, "description": "Response to a 'HasTx' request."
, "required": [ "type", "version", "servicename", "methodname", "result" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/response" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "HasTx" ]
}
, "result":
{ "type": "boolean"
}
, "reflection":
{ "description": "Any value that was set by a client request in the 'mirror' field."
}
}
}

, "SizeAndCapacity":
{ "type": "object"
, "description": "Get size and capacities of the mempool (acquired snapshot)."
, "required": [ "type", "version", "servicename", "methodname" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/request" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "SizeAndCapacity" ]
}
, "args":
{ "type": "object"
, "additionalProperties": false
}
, "mirror":
{ "description": "An arbitrary JSON value that will be mirrored back in the response."
}
}
}

, "SizeAndCapacityResponse":
{ "type": "object"
, "description": "Response to a 'SizeAndCapacity' request."
, "required": [ "type", "version", "servicename", "methodname", "result" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/response" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "SizeAndCapacity" ]
}
, "result":
{ "$ref": "#/definitions/MempoolSizeAndCapacity"
}
, "reflection":
{ "description": "Any value that was set by a client request in the 'mirror' field."
}
}
}

, "ReleaseMempool":
{ "type": "object"
, "description": "Release a previously acquired mempool snapshot."
, "required": [ "type", "version", "servicename", "methodname" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/request" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "ReleaseMempool" ]
}
, "args":
{ "type": "object"
, "additionalProperties": false
}
, "mirror":
{ "description": "An arbitrary JSON value that will be mirrored back in the response."
}
}
}

, "ReleaseMempoolResponse":
{ "type": "object"
, "description": "Response to a 'ReleaseMempool' request."
, "required": [ "type", "version", "servicename", "methodname", "result" ]
, "additionalProperties": false
, "properties":
{ "type":
{ "type": "string"
, "enum": [ "jsonwsp/response" ]
}
, "version":
{ "type": "string"
, "enum": [ "1.0" ]
}
, "servicename":
{ "type": "string"
, "enum": [ "ogmios" ]
}
, "methodname":
{ "type": "string"
, "enum": [ "ReleaseMempool" ]
}
, "result":
{ "type": "string"
, "enum": ["Released"]
}
, "reflection":
{ "description": "Any value that was set by a client request in the 'mirror' field."
}
}
}

, "Query":
{ "type": "object"
, "description": "Query the current ledger tip."
Expand Down Expand Up @@ -2878,6 +3218,17 @@
, "contentEncoding": "base64"
}

, "MempoolSizeAndCapacity":
{ "type": "object"
, "additionalProperties": false
, "required": [ "capacity", "currentSize", "numberOfTxs" ]
, "properties":
{ "capacity": { "$ref": "#/definitions/UInt32" }
, "currentSize": { "$ref": "#/definitions/UInt32" }
, "numberOfTxs": { "$ref": "#/definitions/UInt32" }
}
}

, "Metadata":
{ "type": "object"
, "propertyNames": { "pattern": "^-?[0-9]+$" }
Expand Down
10 changes: 2 additions & 8 deletions server/src/Ogmios/Data/Protocol/TxMonitor.hs
Expand Up @@ -212,9 +212,7 @@ _encodeNextTx
-> Json
_encodeNextTx =
Wsp.mkRequest Wsp.defaultOptions $ \case
NextTx -> encodeObject
[ ( "NextTx", encodeObject [] )
]
NextTx -> encodeObject []

_decodeNextTx
:: Json.Value
Expand Down Expand Up @@ -255,11 +253,7 @@ _encodeHasTx
-> Json
_encodeHasTx encodeTxId =
Wsp.mkRequest Wsp.defaultOptions $ \case
HasTx{id} -> encodeObject
[ ( "HasTx"
, encodeObject [ ( "id", encodeTxId id ) ]
)
]
HasTx{id} -> encodeObject [ ( "id", encodeTxId id ) ]

_decodeHasTx
:: forall block. (FromJSON (GenTxId block))
Expand Down

0 comments on commit 665d192

Please sign in to comment.