Skip to content

Commit

Permalink
re-order sub-protocol hierarchy, to leave room for possible future up…
Browse files Browse the repository at this point in the history
…dates.
  • Loading branch information
KtorZ committed Apr 17, 2021
1 parent 7cc2895 commit eb96b48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/content/mini-protocols/local-chain-sync.md
Expand Up @@ -212,7 +212,7 @@ Note that Ogmios will do its best to pipeline requests to the Cardano node. Neve
Since version `v3.2.0`, Ogmios supports a WebSocket sub-protocol which has an influence on the representation of some data objects. When set, this so-called _compact mode_ will omit proofs, signatures and other voluminous pieces of information from responses that are somewhat superfluous in a trustworthy setup (where for instance, your application fully trusts its node / Ogmios). As a consequence, responses are twice smaller, less bloated and the overall chain-sync synchronization is sped up by about 20%. To enable the compact serialization, use:

```
ogmios.compact.v1
ogmios.v1:compact
```

as a sub-protocol when establishing the WebSocket connection. Omitted fields are documented in the [API reference](../../api-reference) using the `$omitted-if-compact` field of relevant objects.
6 changes: 4 additions & 2 deletions server/src/Ogmios/App/Server/WebSocket.hs
Expand Up @@ -187,10 +187,12 @@ choseSerializationMode
-> (SerializationMode, Maybe SubProtocol)
choseSerializationMode conn =
case subProtocols conn of
[sub] | sub == compact -> (CompactSerialization, Just compact)
sub:_ | sub == compact -> (CompactSerialization, Just compact)
sub:_ | sub == full -> (FullSerialization, Nothing)
_ -> (FullSerialization, Nothing)
where
compact = "ogmios.compact.v1"
full = "ogmios.v1"
compact = full<>":compact"

withOuroborosClients
:: forall m a.
Expand Down
2 changes: 1 addition & 1 deletion server/static/tests/chain-sync.js
Expand Up @@ -34,7 +34,7 @@ const lastAllegraBlock = {
hash: "69c44ac1dda2ec74646e4223bc804d9126f719b1c245dadc2ad65e8de1b276d7"
};

[[], ["ogmios.compact.v1"]].forEach(subProtocols => {
[[], ["ogmios.v1:compact"]].forEach(subProtocols => {
const suffix = subProtocols.length != 0 ? " "+subProtocols : "";
describe("ChainSync"+suffix, () => {
let client;
Expand Down

0 comments on commit eb96b48

Please sign in to comment.