### Install and Run Frontend Source: https://github.com/blinklabs-io/dingo/blob/main/examples/dingo-sundae-preview/README.md Installs frontend dependencies and starts the development server. Configure the DINGO_UTXORPC_URL environment variable to point to your Dingo instance. ```sh npm install DINGO_UTXORPC_URL=http://127.0.0.1:9090 npm run dev -- --host 0.0.0.0 ``` -------------------------------- ### Frontend Development Setup and Run Source: https://github.com/blinklabs-io/dingo/blob/main/examples/dingo-blockfrost-explorer/README.md Install frontend dependencies and start the Vite development server for the Dingo Blockfrost Explorer. Configure Blockfrost and Metrics URLs. ```sh cd examples/dingo-blockfrost-explorer npm install DINGO_BLOCKFROST_URL=http://127.0.0.1:3000 \ DINGO_METRICS_URL=http://127.0.0.1:12798 \ npm run dev -- --host 0.0.0.0 ``` -------------------------------- ### Run Dingo on Preview Network Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Starts Dingo with default settings for the preview network. ```bash ./dingo ``` -------------------------------- ### Demo Script Commands Source: https://github.com/blinklabs-io/dingo/blob/main/internal/test/archive-demo/README.md Commands to run the archive node demonstration. Use './demo.sh' for a guided walkthrough. ```bash ./demo.sh # operator-facing guided demo (~5 min, prints periodic stats) ./start.sh # just bring the stack up ./run-tests.sh # run integration tests (build tag archive_demo) ./stop.sh # tear down ``` -------------------------------- ### Install Business Text Plugin Source: https://github.com/blinklabs-io/dingo/blob/main/docs/dashboards/README.md Installs the dynamic text panel plugin for Grafana. Use the environment variable for Docker/Kubernetes. ```bash grafana-cli plugins install marcusolsson-dynamictext-panel sudo systemctl restart grafana-server ``` ```text GF_INSTALL_PLUGINS=marcusolsson-dynamictext-panel ``` -------------------------------- ### Plugin Registration Example Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Demonstrates how to register a new plugin during package initialization using plugin.Register(). Specify plugin type, name, description, and instantiation function. ```go func init() { plugin.Register(plugin.PluginEntry{ Type: plugin.PluginTypeBlob, // or PluginTypeMetadata Name: "myplugin", Description: "My custom storage plugin", NewFromOptionsFunc: NewFromCmdlineOptions, Options: []plugin.PluginOption{ // Plugin-specific options }, }) } ``` -------------------------------- ### Start and Manage DevNet Containers Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Manually start all DevNet containers, watch logs for specific nodes or all containers, and stop/clean up the environment. ```bash cd internal/test/devnet/ ./start.sh docker compose -f docker-compose.yml logs -f docker compose -f docker-compose.yml logs -f dingo-producer ./stop.sh ``` -------------------------------- ### Deploy Dingo Source: https://github.com/blinklabs-io/dingo/blob/main/examples/dingo-sundae-preview/README.md Deploys the Dingo service on the Preview network. Navigate to the example directory and execute the deployment script. ```sh cd examples/dingo-sundae-preview ./scripts/deploy-dingo.sh ``` -------------------------------- ### Bootstrap Dingo with Mithril Snapshot Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Use this command to bootstrap Dingo by downloading and importing a Mithril snapshot, then start the node. ```bash ./dingo -n preview sync --mithril # Then start the node ./dingo -n preview serve ``` -------------------------------- ### Run Dingo on Mainnet Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Starts Dingo configured for the mainnet using an environment variable. ```bash CARDANO_NETWORK=mainnet ./dingo ``` -------------------------------- ### Running Dingo Devnet Scripts Source: https://github.com/blinklabs-io/dingo/blob/main/internal/test/devnet/README.md Demonstrates how to execute start, stop, and test scripts from different working directories. These scripts resolve their own location. ```bash # from this directory ./start.sh # from the repo root ./internal/test/devnet/start.sh # from anywhere /home/me/dingo/internal/test/devnet/run-tests.sh -run TestBasic ``` -------------------------------- ### Run Dingo on Mainnet with Explicit Config Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Starts Dingo for the mainnet, specifying a custom configuration file path via an environment variable. ```bash CARDANO_NETWORK=mainnet CARDANO_CONFIG=path/to/mainnet/config.json ./dingo ``` -------------------------------- ### Core Plugin Implementation Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Implement the plugin.Plugin interface with Start and Stop methods for resource management. This is the main struct for your plugin's logic. ```go type MyPlugin struct { // Fields } func (p *MyPlugin) Start() error { // Initialize resources return nil } func (p *MyPlugin) Stop() error { // Clean up resources return nil } ``` -------------------------------- ### Get Live UTXOs with Assets by Payment Key (Postgres) Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Retrieves all live UTXOs and their associated assets for a given payment key. The results are ordered by the slot they were added, then by output index. ```sql SELECT encode(u.tx_id, 'hex') AS tx_id, u.output_idx, u.amount, encode(a.policy_id, 'hex') AS policy_id, encode(a.name, 'hex') AS asset_name, a.amount AS asset_amount FROM utxo u LEFT JOIN asset a ON a.utxo_id = u.id WHERE u.deleted_slot = 0 AND u.payment_key = decode($1, 'hex') ORDER BY u.added_slot DESC, u.output_idx DESC; ``` -------------------------------- ### Get Tip Information Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Retrieves the current tip of the blockchain. This is a simple query to get the latest block information. ```sql SELECT * FROM tip WHERE id = 1; ``` -------------------------------- ### Starting and Stopping Dingo Devnet Source: https://github.com/blinklabs-io/dingo/blob/main/internal/test/devnet/README.md Basic commands to start the devnet with services running in the background and to stop and clean up the devnet. ```bash ./start.sh # docker compose up -d (configurator runs first, then nodes) ./stop.sh # docker compose down -v (also removes volumes) ``` -------------------------------- ### Test Plugin Configuration with Environment Variables Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Demonstrates how to test a specific plugin ('myplugin') by setting its options via environment variables. This is useful for verifying configuration loading. ```bash DINGO_DATABASE_BLOB_MYPLUGIN_OPTION1=value ./dingo --blob myplugin ``` -------------------------------- ### Select Database Plugins via Command Line Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Use command-line flags to specify blob and metadata storage plugins. ```bash ./dingo --blob gcs --metadata sqlite ``` -------------------------------- ### Run Full Conformance Suite Source: https://github.com/blinklabs-io/dingo/blob/main/internal/test/conformance/README.md Execute all ledger rules conformance tests for the Dingo project. ```bash go test ./internal/test/conformance/ ``` -------------------------------- ### Register Plugin Entry Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Register your plugin using plugin.Register in the init function. Provide type, name, description, constructor, and option definitions. ```go var cmdlineOptions struct { option1 string option2 int } func init() { plugin.Register(plugin.PluginEntry{ Type: plugin.PluginTypeBlob, Name: "myplugin", Description: "My custom plugin", NewFromOptionsFunc: NewFromCmdlineOptions, Options: []plugin.PluginOption{ { Name: "option1", Type: plugin.PluginOptionTypeString, Description: "First option", DefaultValue: "default", Dest: &cmdlineOptions.option1, }, // More options... }, }) } ``` -------------------------------- ### Plugin Interface Definition Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Defines the essential Start and Stop methods required for all Dingo plugins. ```go type Plugin interface { Start() error Stop() error } ``` -------------------------------- ### Get Total Active Stake Source: https://github.com/blinklabs-io/dingo/blob/main/ARCHITECTURE.md Returns the total active stake across the network for a given epoch. ```go // Get total active stake totalStake, err := ledgerView.GetTotalActiveStake(epoch) ``` -------------------------------- ### Plugin Constructor with Options Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Implement a constructor that accepts variadic OptionFunc arguments to configure the plugin. This allows for flexible initialization. ```go func NewWithOptions(opts ...OptionFunc) (*MyPlugin, error) { p := &MyPlugin{} for _, opt := range opts { opt(p) } return p, nil } ``` -------------------------------- ### Run Dingo with Local Binary Source: https://github.com/blinklabs-io/dingo/blob/main/examples/dingo-gov-lens/README.md This section details how to run Dingo with a local binary, setting up the environment variables for database connection and Dingo configuration. It includes running the mithril sync script and then starting the Dingo server. ```sh cd examples/dingo-gov-lens export DATABASE_URL='host=127.0.0.1 port=5432 user=dingo password=change-me dbname=dingo_metadata sslmode=disable TimeZone=UTC' export DINGO_BIN=/path/to/dingo ./scripts/mithril-sync.sh ./scripts/run-dingo.sh ``` -------------------------------- ### Get Stake for a Specific Pool Source: https://github.com/blinklabs-io/dingo/blob/main/ARCHITECTURE.md Fetches the stake amount for a particular pool within a specified epoch. ```go // Get stake for a specific pool poolStake, err := ledgerView.GetPoolStake(epoch, poolKeyHash) ``` -------------------------------- ### Run Linters and Formatters with Pre-commit Source: https://github.com/blinklabs-io/dingo/blob/main/CLAUDE.md Execute golangci-lint, nilaway, and modernize for code quality checks and formatting. Use the --fix flag with modernize to automatically apply changes. ```shell golangci-lint run ./ nilaway ./ modernize ./... # --fix to auto-apply ``` -------------------------------- ### Get Script by Hash Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Retrieves script information from the database using its hash. The hash should be provided in hexadecimal format. ```sql SELECT * FROM script WHERE hash = decode($1, 'hex'); ``` -------------------------------- ### List Available Dingo Plugins Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Execute the 'list' command to view all available storage plugins and their descriptions. ```bash ./dingo list ``` -------------------------------- ### Plugin Registration Flow Source: https://github.com/blinklabs-io/dingo/blob/main/ARCHITECTURE.md Illustrates the sequence of calls for registering and retrieving plugins. Use this flow to understand how plugins are managed within the system. ```Go plugin.SetPluginOption() -> plugin.GetPlugin() -> plugin.Start() -> Use interface ``` -------------------------------- ### Get Datum by Hash Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Fetches datum information from the database using its hash. The hash is expected to be provided in hexadecimal format. ```sql SELECT * FROM datum WHERE hash = decode($1, 'hex'); ``` -------------------------------- ### Chainsync Header-Sync Strategy Configuration Source: https://github.com/blinklabs-io/dingo/blob/main/ARCHITECTURE.md Explains the different header-sync strategies ('primary', 'parallel', 'round-robin') and how they are configured via YAML, environment variables, or CLI flags. ```go The strategy is set via `chainsync.strategy` (YAML), `DINGO_CHAINSYNC_STRATEGY` (env), or `--chainsync-strategy` (CLI). ``` -------------------------------- ### Get Script Locked Supply Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Calculates the total amount of Lovelace locked in UTxOs whose payment credential is a script and are not deleted. ```sql SELECT COALESCE(SUM(amount), 0) AS locked_supply FROM utxo WHERE payment_script = true AND deleted_slot = 0; ``` -------------------------------- ### Select Database Plugins via Environment Variables Source: https://github.com/blinklabs-io/dingo/blob/main/README.md Set environment variables to configure the blob and metadata storage plugins. ```bash DINGO_DATABASE_BLOB_PLUGIN=gcs DINGO_DATABASE_METADATA_PLUGIN=sqlite ``` -------------------------------- ### Get Stake Distribution for Leader Election Source: https://github.com/blinklabs-io/dingo/blob/main/ARCHITECTURE.md Retrieves the full stake distribution for a given epoch, essential for Ouroboros Praos leader election. ```go // Get full stake distribution for leader election dist, err := ledgerView.GetStakeDistribution(epoch) ``` -------------------------------- ### Dingo Node Initialization Flow Source: https://github.com/blinklabs-io/dingo/blob/main/ARCHITECTURE.md Outlines the sequential steps involved in initializing the Dingo node's components when `Node.Run()` is called. This order is critical for proper system startup. ```text 1. EventBus creation in `New`, plus tracing/runtime metrics setup in `Run` 2. Database loading (blob + metadata plugins) 3. ChainManager initialization and block-proposed event subscription 4. Ouroboros protocol handler creation 5. LedgerState creation (UTXO tracking, validation) 6. Bark remote archive adapter and History Expiry worker (if configured) 7. Database recovery, if startup detects a recoverable timestamp conflict 8. LedgerState start 9. Snapshot manager start (captures genesis snapshot, or reuses an existing post-Mithril Mark snapshot window) 10. Mempool setup and injection into LedgerState/Ouroboros 11. ChainsyncState (multi-client tracking, stall detection) 12. ChainSelector (genesis/Praos comparison) start 13. ConnectionManager creation and event wiring 14. PeerGovernor creation/start (topology + churn + ledger peers) 15. ConnectionManager listener start 16. Stalled client recycler (background goroutine) 17. UTxO RPC server (if API storage mode and port configured) 18. Bark C2/archive server (if port configured) 19. Blockfrost API (if API storage mode and port configured) 20. Mesh API (if API storage mode and port configured) 21. Off-chain metadata fetcher (if API storage mode) 22. Block forger + leader election (if block producer mode) 23. Wait for shutdown signal ``` -------------------------------- ### Constructor for Command-Line Options Source: https://github.com/blinklabs-io/dingo/blob/main/database/plugin/PLUGIN_DEVELOPMENT.md Implement a constructor function that is called when the plugin is instantiated from command-line options. It should handle errors by panicking. ```go func NewFromCmdlineOptions() plugin.Plugin { p, err := NewWithOptions( WithOption1(cmdlineOptions.option1), WithOption2(cmdlineOptions.option2), ) if err != nil { panic(err) } return p } ``` -------------------------------- ### Get Protocol Parameter Updates Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Retrieves protocol parameter updates for the current and previous epochs. This is useful for understanding changes in protocol parameters over time. ```sql -- For epoch 0, use WHERE epoch = 0. For later epochs: SELECT * FROM pparam_update WHERE epoch IN ($1, $1 - 1) ORDER BY id DESC; ``` -------------------------------- ### Run Conformance Suite with Per-Vector Statistics Source: https://github.com/blinklabs-io/dingo/blob/main/internal/test/conformance/README.md Execute conformance tests and report per-vector pass/fail statistics for progress tracking. ```bash go test -v ./internal/test/conformance/ -run TestRulesConformanceVectorsWithResults ``` -------------------------------- ### Get Pool Registration History Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Retrieves the historical registration data for a specific pool, ordered by the slot it was added, block index, and certificate index. ```sql -- Postgres SELECT pr.added_slot, t.block_index, c.cert_index, encode(pr.pool_key_hash, 'hex') AS pool_key_hash, pr.pledge, pr.cost, pr.margin, pr.metadata_url FROM pool_registration pr JOIN certs c ON c.id = pr.certificate_id JOIN "transaction" t ON t.id = c.transaction_id WHERE pr.pool_key_hash = decode($1, 'hex') ORDER BY pr.added_slot DESC, t.block_index DESC, c.cert_index DESC; ``` -------------------------------- ### Get Account Information Source: https://github.com/blinklabs-io/dingo/blob/main/DATABASE.md Fetches the latest delegation state for a given account, identified by its staking key. The staking key is expected to be provided as a hex-encoded string. ```sql -- Postgres SELECT encode(a.staking_key, 'hex') AS staking_key, encode(a.pool, 'hex') AS pool_key_hash, encode(a.drep, 'hex') AS drep, a.drep_type, a.reward, a.active FROM account a WHERE a.staking_key = decode($1, 'hex'); ```