helium/blockchain-node

Allow lookup of vars via JSONRPC

Closed this issue · 0 comments

Feature request: Enable a JSONRPC endpoint that allows the user to retrieve the value of a chain var. It would be extremely useful to have access to var values directly from the node.

e.g.
Request:

{
  "jsonrpc": "2.0",
  "id": "1234567890",
  "method": "vars_get",
  "params": {
    "var": "alpha_decay"
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": "1234567890",
  "result": {
    "var": "alpha_decay",
    "type": "float",
    "value": 0.0035
   }
}

(or something similar)

The vars are available in the default CF of ledger.db with a $var_ prefix, so hopefully it is just a lookup + decode operation.
https://github.com/helium/blockchain-core/blob/c48120bebc3de89f1e0a9624eb4ffc536f41ba29/src/ledger/v1/blockchain_ledger_v1.erl#L5368