### Start Ogmios and Cardano Node with Docker Compose Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/docker.md Launches the Ogmios and cardano-node stack using docker-compose. This setup connects Ogmios to a mainnet cardano-node. ```bash docker-compose up ``` -------------------------------- ### Install Ogmios Server Executable Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Install the Ogmios server executable to a location where it can be run directly. Use --overwrite-policy=always to ensure the latest version is installed. ```bash $ cabal install ogmios:exe:ogmios --install-method=copy --overwrite-policy=always $ ogmios --help ``` -------------------------------- ### Install Ogmios with Homebrew Source: https://github.com/cardanosolutions/ogmios/blob/master/README.md Use Homebrew to tap the CardanoSolutions formulas and install Ogmios. Ensure your Homebrew is up-to-date. ```bash brew tap CardanoSolutions/formulas brew install ogmios ``` -------------------------------- ### Run Cardano Node with Ogmios Docker Image Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/docker.md This command starts a Docker container for the cardano-node-ogmios image, exposing the necessary ports and mounting a volume for database persistence. Use this for a quick setup of a Cardano node with Ogmios. ```docker docker run -it \ --name cardano-node-ogmios \ -p 1337:1337 \ -v cardano-node-ogmios-mainnet-db:/db \ cardanosolutions/cardano-node-ogmios:latest ``` -------------------------------- ### Build and install blst library Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Clone the blst repository, checkout a specific version, build the library, and install it along with its pkg-config file and headers. This is a prerequisite for building Ogmios manually. ```bash git clone https://github.com/supranational/blst cd blst git checkout v0.3.10 ./build.sh cat > libblst.pc << EOF prefix=/usr/local exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: libblst Description: Multilingual BLS12-381 signature library URL: https://github.com/supranational/blst Version: 0.3.10 Cflags: -I${includedir} Libs: -L${libdir} -lblst EOF sudo cp libblst.pc /usr/local/lib/pkgconfig/ sudo cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp /usr/local/include/ sudo cp libblst.a /usr/local/lib sudo chmod u=rw,go=r /usr/local/{lib/{libblst.a,pkgconfig/libblst.pc},include/{blst.{h,hpp},blst_aux.h}} ``` -------------------------------- ### Example Query Request Source: https://github.com/cardanosolutions/ogmios/blob/master/architectural-decisions/accepted/017-api-version-6-major-rewrite.md This is an example of a query request sent to the local-state-query protocol. ```json { "jsonrpc": "2.0", "method": "queryLedgerState/tip", } ``` -------------------------------- ### Example Query Response Source: https://github.com/cardanosolutions/ogmios/blob/master/architectural-decisions/accepted/017-api-version-6-major-rewrite.md This is an example of a response from the local-state-query protocol, now properly linked to its parent query. ```json { "jsonrpc": "2.0", "method": "queryLedgerState/tip", "result": { "slot": 1234, "id": "1234567890abcdef" } } ``` -------------------------------- ### Query Start Time Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md Gets the start time of the Cardano blockchain. ```APIDOC ## queryNetwork/startTime ### Description Retrieves the start time of the blockchain. ### Method POST ### Endpoint /queryNetwork ### Request Body ```json { "jsonrpc": "2.0", "method": "queryNetwork/startTime", "id": null } ``` ``` -------------------------------- ### Install and Build Ogmios TypeScript Packages Source: https://github.com/cardanosolutions/ogmios/blob/master/clients/TypeScript/README.md Installs dependencies and builds all packages within the Yarn workspace. Ensure you have Yarn installed. ```console yarn install && \ yarn build ``` -------------------------------- ### Query Network: Start Time Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md This JSON-RPC method queries the start time of the network. ```json { "jsonrpc": "2.0", "method": "queryNetwork/startTime" } ``` -------------------------------- ### Query Ledger State: Era Start Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md Gets the start time of the current era. This query requires no parameters. ```json { "jsonrpc": "2.0", "method": "queryLedgerState/eraStart" } ``` -------------------------------- ### Build Documentation with Hugo Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Build the project documentation using Hugo. Ensure you have an extended version of Hugo installed (>= 0.96.0). ```bash hugo # or, alternatively for a development setup on http://localhost:1313 hugo serve ``` -------------------------------- ### Chart Initialization Logic Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Executes the initial setup for the chart, including notifying plugins, handling responsiveness, and binding events. Call this after the chart instance is created. ```javascript _initialize(){ return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():el(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this } ``` -------------------------------- ### Ogmios JSON-RPC Request Example Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/basics.md This is an example of a valid JSON-RPC request message sent to Ogmios. It specifies the method, parameters, and a unique ID for tracking. ```json { "jsonrpc": "2.0", "method": "findIntersection", "params": { "points": [ "origin" ] }, "id": "init-1234-5678" } ``` -------------------------------- ### Ogmios JSON-RPC Response Example Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/basics.md This is an example of a successful JSON-RPC response from Ogmios. It includes the method, the result of the operation, and the original request ID. ```json { "jsonrpc": "2.0", "method": "findIntersection", "result": { "intersection": "origin", "tip": { "id": "d184f428159290bf3558b4d1d139e6a07ec6589738c28a0925a7ab776bde4d62", "blockNo": 4870185, "slot": 12176171 } }, "id": "init-1234-5678" } ``` -------------------------------- ### Build Ogmios TypeScript Client with Yarn Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Install dependencies and build the TypeScript client project using Yarn. ```bash $ yarn && yarn build ``` -------------------------------- ### Query Ledger State: Era Start Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md Retrieves the start time of the current era from the ledger state. ```APIDOC ## queryLedgerState/eraStart ### Description Retrieves the start time of the current era from the ledger state. ### Method POST ### Endpoint /query ### Request Body ```json { "jsonrpc": "2.0", "method": "queryLedgerState/eraStart" } ``` ### Response #### Success Response (200) - **eraStart** (string) - The ISO 8601 timestamp of the current era's start. ### Response Example ```json { "jsonrpc": "2.0", "result": { "eraStart": "2023-01-01T00:00:00Z" } } ``` ``` -------------------------------- ### Install libsecp256k1 on MacOS Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md On MacOS, if libsecp256k1 is not found in /usr/local/lib, use install_name_tool to adjust its ID. ```bash install_name_tool -id /usr/local/lib/libsecp256k1.0.dylib /usr/local/lib/libsecp256k1.0.dylib ``` -------------------------------- ### Render Chart Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Renders the chart, ensuring it's attached and not already running, then starts the animation loop. ```javascript render(){ !1!==this.notifyPlugins("beforeRender",{cancelable:!0})&& (t_.has(this)?this.attached&&!t_.running(this)&&t_.start(this): (this.draw(),sw({chart:this}))) } ``` -------------------------------- ### Query Ledger Tip Source: https://github.com/cardanosolutions/ogmios/blob/master/clients/TypeScript/packages/repl/README.md Use `ledgerTip()` to get the current tip of the ledger, including its ID and slot. ```javascript ogmios> await ledgerTip() { id: '41364e89e44370a009f083ce9963261aabf6138db519b039012232bf40f187f8', slot: 25541023 } ``` -------------------------------- ### Initialize Offsets Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Calculates and sets the start, end, and factor offsets for the scale. These are used for positioning ticks and data points accurately. ```javascript initOffsets(t=[]){let e,i,s=0,a=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),s=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,i=this.getDecimalForValue(t[t.length-1]),a=1===t.length?i:(i-this.getDecimalForValue(t[t.length-2]))/2);let n=t.length<3?.5:.25;s=tt(s,0,n),a=tt(a,0,n),this._offsets={start:s,end:a,factor:1/(s+1+a)}} ``` -------------------------------- ### Send HTTP POST Request to Ogmios Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/basics.md This example demonstrates sending a JSON-RPC request, such as 'submitTransaction', via an HTTP POST request. It's suitable for stateless operations. ```javascript const fetch = require('fetch'); fetch("http://localhost:1337", { method: "POST", data: { "jsonrpc": "2.0", "method": "submitTransaction", "params": { "transaction": "..." } } }).then(async response => { const json = await response.json(); // do something with 'response' }); ``` -------------------------------- ### Plugin Notification System Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Handles the notification of plugins about various chart events like initialization, destruction, and state changes. It ensures plugins are correctly started, stopped, installed, and uninstalled. ```javascript class sr{ constructor(){this._init=[]} notify(t,e,i,s){ "beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")) let a=s?this._descriptors(t).filter(s):this._descriptors(t) let n=this._notify(a,t,e,i) "afterDestroy"===e&&(this._notify(a,t,"stop"),this._notify(this._init,t,"uninstall")) return n } _notify(t,e,i,s){ for(let a of(s=s||{},t)){ let t=a.plugin if(!1===f(t[i],[e,s,a.options],t)&&s.cancelable)return!1 } return!0 } invalidate(){ n(this._cache)||(this._oldCache=this._cache,this._cache=void 0) } _descriptors(t){ if(this._cache)return this._cache let e=this._cache=this._createDescriptors(t) return this._notifyStateChanges(t),e } _createDescriptors(t,e){ let i=t&&t.config, s=d(i.options&&i.options.plugins,{}), a=function(t){ let e={},i=[],s=Object.keys(sn.plugins.items) for(let t=0;tt.filter(t=>!e.some(e=>t.plugin.id===e.plugin.id)) this._notify(s(e,i),t,"stop"), this._notify(s(i,e),t,"start") } } function so(t,e){let ``` -------------------------------- ### Initialize Chart for Memory Usage Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Sets up a Chart.js instance to visualize the Ogmios heap size over time. Includes basic chart options and event listeners for resizing. ```javascript window.charts={},charts.currentHeapSize=new Chart(document.querySelector("canvas#max-heap-size").getContext("2d"),{type:"line",options:{tooltips:{mode:"index",intersect:!1},hover:{mode:"nearest",intersect:!0},backgroundColor:"#5755d9",borderColor:"#5755d9"},data:{labels:\[\] ,datasets:\[{label:"Heap size (KB)",fill:!0,data:\[\]}\]}}),window.addEventListener("resize",debounce(()=>charts.currentHeapSize.resize(),50)); ``` -------------------------------- ### Chart Initialization and Configuration Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Initializes a new chart instance with provided context, options, and event listeners. Handles chart acquisition and basic setup. Use when creating a new chart on the dashboard. ```javascript r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||ij(s)),this.platform.updateConfig(i);let o=this.platform.acquireContext(s,r.aspectRatio),l=o&&o.canvas,h=l&&l.height,d=l&&l.width;this.id=a(),this.ctx=o,this.canvas=l,this.width=d,this.height=h,this. _options=r,this. _aspectRatio=this.aspectRatio,this. _layers=\[\];this. _metasets=\[\];this. _stacks=void 0,this.boxes=\[\];this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this. _active=\[\];this. _lastEvent=void 0,this. _listeners={},this. _responsiveListeners=void 0,this. _sortedMetasets=\[\];this.scales={},this. $proxies={},this. _hiddenIndices={},this.attached=!1,this. _animationsDisabled=void 0,this.$context=void 0,this. _doResize=tf(t=>this.update(t),r.resizeDelay||0),this. _dataChanges=\[\];sP\[this.id\]=this,o&&l?(t _.listen(this,"complete",sw),t _.listen(this,"progress",sk),this. _initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")} ``` -------------------------------- ### Run Ogmios Server with Cabal Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Execute the compiled Ogmios server using cabal's run command. Use the --help flag to see available options. ```bash $ cabal run ogmios:exe:ogmios -- --help ``` -------------------------------- ### Handle Dashboard Ready Event Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Configures the UI to display the main dashboard content when the server connection is established and ready. Hides loading and empty states. ```javascript on(EVENTS.DASHBOARD_READY,s=>{sel("body").style.height="auto",sel("div#loading").classList.add("d-none"),sel("div#empty").classList.add("d-none"),sel("div#dashboard").classList.remove("d-none")}); ``` -------------------------------- ### Main Application with Concurrent Tracing Source: https://github.com/cardanosolutions/ogmios/blob/master/server/modules/contra-tracers/README.md The main function demonstrates how to initialize and use tracers for concurrent HTTP and DB applications. It uses 'withStdoutTracer' to set up logging to standard output. ```haskell main :: IO () main = do withStdoutTracer mempty emptyConfiguration $ \tracers -> do concurrently_ (myHttpApplication (tracerHttp tracers)) (myDbApplication (tracerDb tracers)) ``` -------------------------------- ### Run Ogmios Standalone with Docker Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/docker.md Starts a standalone Ogmios container, connecting to a running cardano-node via its domain socket. Ensure the host argument is used to bind the server from within the container. ```bash docker run --rm \ --name ogmios \ -p 1337:1337 \ -v ./ipc:/ipc \ cardanosolutions/ogmios:latest \ --node-socket /ipc/node.socket \ --node-config /config/mainnet/cardano-node/config.json \ --host 0.0.0.0 ``` -------------------------------- ### Scatter Controller Get Label and Value Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Retrieves the label and formatted value for a data point in a scatter chart. It uses the x and y scales to get the corresponding labels for the point's coordinates. ```javascript getLabelAndValue(t){let e=this._cachedMeta,i=this.chart.data.labels||"",{xScale:s,yScale:a}=e,n=this.getParsed(t),r=s.getLabelForValue(n.x),o=a.getLabelForValue(n.y);return{label:i[t]||"",value:"("+r+", "+o+")"}} ``` -------------------------------- ### Connect and Monitor Mempool Transactions Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-tx-monitor.md Connect to the Ogmios WebSocket endpoint and monitor mempool transactions. This example shows how to acquire the mempool, process incoming transaction notifications, and request the next transaction. ```javascript const WebSocket = require('ws'); const client = new WebSocket("ws://localhost:1337"); // Helper function function rpc(method, params) { client.send(JSON.stringify({ jsonrpc: '2.0', method, params })); } client.on('message', e => { const message = JSON.parse(e); if (message?.result?.transaction === null) { rpc('acquireMempool'); } else { console.log(message.result); // Returns transaction id rpc('nextTransaction'); // Returns all transaction information // rpc("nextTransaction", { fields: "all" }); } }); client.once('open', () => { rpc('acquireMempool'); }); ``` -------------------------------- ### Display Server Entrypoints Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Updates the UI to show the WebSocket and HTTP URLs for connecting to the Ogmios server. This is triggered when the entrypoints event is received. ```javascript on(EVENTS.ENTRYPOINTS,({websocketUrl:e,httpUrl:n})=>{sel("#websocket-url").innerText=e,sel("#http-url").innerText=n}); ``` -------------------------------- ### Query Tip Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md Gets the current tip of the Cardano blockchain. ```APIDOC ## queryNetwork/tip ### Description Retrieves the current tip of the blockchain. ### Method POST ### Endpoint /queryNetwork ### Request Body ```json { "jsonrpc": "2.0", "method": "queryNetwork/tip", "id": null } ``` ``` -------------------------------- ### Get Dataset Meta Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Retrieves or creates the metadata for a specific dataset. ```javascript getDatasetMeta(t){ let e=this.data.datasets[t], i=this._metasets, s=i.filter(t=>t&&t._dataset===e).pop(); return s|| (s={ type:null, data:[], dataset:null, controller:null, hidden:null, xAxisID:null, yAxisID:null, order:e&&e.order||0, index:t, _dataset:e, _parsed:[], _sorted:!1 },i.push(s)), s } ``` -------------------------------- ### Run Docker Compose for Specific Network and Port Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/docker.md Launches the Ogmios and cardano-node stack for a specific network (e.g., preprod) and custom port, using the --project-name flag to manage separate network configurations. ```bash NETWORK=preprod OGMIOS_PORT=1338 docker-compose --project-name cardano-ogmios-preprod up ``` -------------------------------- ### Get Visible Dataset Count Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Counts the number of datasets that are currently visible. ```javascript getVisibleDatasetCount(){ return this.getSortedVisibleDatasetMetas().length } ``` -------------------------------- ### Query Block Height Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md Gets the current block height of the Cardano blockchain. ```APIDOC ## queryNetwork/blockHeight ### Description Retrieves the current block height of the blockchain. ### Method POST ### Endpoint /queryNetwork ### Request Body ```json { "jsonrpc": "2.0", "method": "queryNetwork/blockHeight", "id": null } ``` ``` -------------------------------- ### Get Data Visibility Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Retrieves the visibility state of a specific data point index. ```javascript getDataVisibility(t){ return!this._hiddenIndices[t] } ``` -------------------------------- ### Render AsyncAPI Documentation Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/layouts/api/list.html Renders the AsyncAPI documentation on the page. Specify the schema URL and configuration options to customize the display. ```javascript AsyncApiStandalone.render({ schema: { url: '/api/specification.yaml', }, config: { show: { messages: false }, }, }, document.getElementById('asyncapi')); ``` -------------------------------- ### Query Cardano Mainnet Stake Distribution Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md This JavaScript example demonstrates a full interaction with Ogmios to fetch the stake distribution of all Cardano mainnet stake pools. It first queries the network tip, then acquires the ledger state at that tip, and finally requests the live stake distribution. Ensure a WebSocket connection to Ogmios is established. ```javascript const WebSocket = require('ws'); const client = new WebSocket("ws://localhost:1337"); function rpc(method, params = {}, id) { client.send(JSON.stringify({ jsonrpc: "2.0", method, params, id })); } client.once('open', () => { rpc("queryNetwork/tip", {}) }); client.on('message', function(msg) { const response = JSON.parse(msg); switch (response.method) { case "queryNetwork/tip": const point = response.result; rpc("acquireLedgerState", { point }); break; case "acquireLedgerState": rpc("queryLedgerState/liveStakeDistribution"); break; default: console.log(response.result); client.close(); break; } }); ``` -------------------------------- ### Get Legend Item at Coordinates Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Retrieves the legend item that is located at the specified x and y coordinates. ```javascript _getLegendItemAt(t,e){ let i,s,a; if(ti(t,this.left,this.right)&&ti(e,this.top,this.bottom)){ for(a=this.legendHitBoxes,i=0;i { // Burst the server's queue with a few requests. for (let i = 0; i < 100; i += 1) { client.send(nextBlock); } }); client.on('message', msg => { client.send(nextBlock); // Ask for next request immediately doSomething(msg); }) ``` -------------------------------- ### Query Network Tip Protocol Parameters Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-state-query.md Connects to a local Ogmios instance via WebSocket to query the latest protocol parameters. Requires the 'ws' library. The response is logged to the console. ```javascript const WebSocket = require('ws'); const client = new WebSocket("ws://localhost:1337"); function rpc(method, params = {}, id) { client.send(JSON.stringify({ jsonrpc: "2.0", method, params, id })); } client.once('open', () => { rpc("queryLedgerState/protocolParameters"); }); client.on('message', function(msg) { const response = JSON.parse(msg); console.log(JSON.stringify(response.result, null, 4)); client.close(); }); ``` ```json { "minFeeCoefficient": 44, "minFeeConstant": { "lovelace": 155381 }, "maxBlockBodySize": { "bytes": 90112 }, "maxBlockHeaderSize": { "bytes": 1100 }, "maxTransactionSize": { "bytes": 16384 }, "stakeCredentialDeposit": { "lovelace": 2000000 }, "stakePoolDeposit": { "lovelace": 500000000 }, "stakePoolRetirementEpochBound": 18, "desiredNumberOfStakePools": 500, "stakePoolPledgeInfluence": "3/10", "monetaryExpansion": "3/1000", "treasuryExpansion": "1/5", "minStakePoolCost": { "lovelace": 340000000 }, "minUtxoDepositConstant": 0, "minUtxoDepositCoefficient": 4310, "plutusCostModels": { "plutus:v1": [ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32, 1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924, 473, 1, 208896, 511, 1, 52467, 32, 64832 ], "plutus:v2": [ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32, 1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924, 473, 1, 208896, 511, 1, 52467, 32, 64832 ] }, "scriptExecutionPrices": { "memory": '577/10000', "cpu": '721/10000000' }, "maxExecutionUnitsPerTransaction": { "memory": 14000000, "cpu": 10000000000 }, "maxExecutionUnitsPerBlock": { "memory": 62000000, "cpu": 20000000000 }, "maxValueSize": { "bytes": 5000 }, "collateralPercentage": 150, "maxCollateralInputs": 3, "version": { "major": 8, "minor": 0 } } ``` -------------------------------- ### Initialize Memory Usage Chart Source: https://github.com/cardanosolutions/ogmios/blob/master/server/dashboard/dashboard.html Initializes a line chart to display Ogmios' current heap size. It sets up chart options, data structure, and event listeners for resizing. ```javascript window.charts = {} charts.currentHeapSize = new Chart(document.querySelector('canvas#max-heap-size').getContext('2d'), { type: 'line', options: { tooltips: { mode: 'index', intersect: false }, hover: { mode: 'nearest', intersect: true }, backgroundColor: '#5755d9', borderColor: '#5755d9', }, data: { labels: [], datasets: [ { label: 'Heap size (KB)', fill: true, data: [], } ], }, }); window.addEventListener("resize", debounce(() => charts.currentHeapSize.resize(), 50)); ``` -------------------------------- ### Get Tooltip Caret Position Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Calculates the coordinates for the tooltip's caret based on alignment and dimensions. ```javascript getCaretPosition(t,e,i){let s,a,n,r,o,l;let{xAlign:h,yAlign:d}=this,{caretSize:c,cornerRadius:u}=i,{topLeft:f,topRight:g,bottomLeft:p,bottomRight:m}=e5(u),{x:b,y:x}=t,{width:_,height:y}=e;return"center"===d?(o=x+y/2,"left"===h?(a=(s=b)-c,r=o+c,l=o-c):"right"===h?(a=(s=b+_)+c,r=o-c,l=o+c),n=s):("left"===h?b+Math.max(f,p)+c:"right"===h?b+_-Math.max(g,m)-c:this.caretX,"top"===d?(o=(r=x)-c,s=a-c,n=a+c):"bottom"===d?(o=(r=x+y)+c,s=a+c,n=a-c),l=r),{x1:s,x2:a,x3:n,y1:r,y2:o,y3:l}} ``` -------------------------------- ### Get Sorted Visible Dataset Metas Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Returns an array of dataset metadata objects that are currently visible. ```javascript getSortedVisibleDatasetMetas(){ return this._getSortedDatasetMetas(!0) } ``` -------------------------------- ### Compile Ogmios Server with Cabal Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Compile the Ogmios server executable using cabal. This may take time on the first run due to dependency downloads. ```bash $ cabal update $ cabal build ogmios:exe:ogmios ``` -------------------------------- ### Get Own Keys from Scopes Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Collects and returns all unique own keys from a list of scopes, excluding private properties. ```javascript function eI(t){let e=t._keys;return e||(e=t._keys=function(t){let e=new Set;for(let i of t)for(let t of Object.keys(i).filter(t=>!t.startsWith("_")))e.add(t);return Array.from(e)}(t._scopes)),e} ``` -------------------------------- ### Display Entrypoint URLs Source: https://github.com/cardanosolutions/ogmios/blob/master/server/dashboard/dashboard.html Updates the UI with the WebSocket and HTTP URLs for the Ogmios server entrypoints. This snippet is triggered when the ENTRYPOINTS event is received. ```javascript on(EVENTS.ENTRYPOINTS, ({ websocketUrl, httpUrl }) => { sel('#websocket-url').innerText = websocketUrl; sel('#http-url').innerText = httpUrl; }) ``` -------------------------------- ### Pipelining Requests with WebSocket Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/mini-protocols/local-chain-sync.md Demonstrates how to leverage request pipelining over WebSocket to maximize bandwidth utilization. Clients should send multiple requests at once and immediately send a new request upon receiving a response to maintain a high throughput. ```APIDOC ## WebSocket Pipelining Example ### Description This example shows a JavaScript client using WebSocket to pipeline requests to Ogmios. It sends an initial burst of requests and then sends a new `nextBlock` request immediately after processing each received message, ensuring continuous data flow. ### Method WebSocket send() ### Endpoint (WebSocket connection) ### Parameters (None for the `nextBlock` method itself, but the client manages the request queue) ### Request Example (JavaScript) ```javascript const nextBlock = JSON.stringify({ "jsonrpc": "2.0", "method": "nextBlock", }); client.on('open', () => { // Burst the server's queue with a few requests. for (let i = 0; i < 100; i += 1) { client.send(nextBlock); } }); client.on('message', msg => { client.send(nextBlock); // Ask for next request immediately doSomething(msg); }) ``` ### Recommendations - Pipelining **50-100 requests** is a good starting point for most standard machines. - Adjust the number of pipelined requests based on application and machine resources. - Ensure timely collection and handling of responses to avoid diminishing returns from excessive pipelining. ``` -------------------------------- ### Get Chart Context Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Provides the rendering context for a specific tick or the scale itself. Used for applying styles and configurations. ```javascript getContext(t){let e=this.ticks||[];if(t>=0&&tnew Set(t.filter(t=>t[0]===e).map((t,e)=>e+","+t.splice(1).join(","))), s=i(0); for(let t=1;tt.split(",")).map(t=>({method:t[1],start:+t[2],count:+t[3]})) } ``` -------------------------------- ### Run Unit Tests with Cabal Source: https://github.com/cardanosolutions/ogmios/blob/master/docs/content/getting-started/building.md Execute all unit tests for the Ogmios project using cabal test all. ```bash $ cabal test all ``` -------------------------------- ### Get Label Timestamps Source: https://github.com/cardanosolutions/ogmios/blob/master/server/static/dashboard.html Retrieves and caches all label values (timestamps) from the chart's labels. Normalizes the data if it hasn't been already. ```javascript getLabelTimestamps(){let t,e;let i=this._cache.labels||[];if(i.length)return i;let s=this.getLabels();for(t=0,e=s.length;t