如何使用SQL查询检索NEAR区块链上的验证器数量?

huangapple go评论70阅读模式
英文:

how can i retrieve the number of validators on NEAR blockchain using SQL query?

问题

以下是翻译好的部分:

NEAR区块链基于权益证明协议。验证器的数量可以基于验证者的“质押”或者“未质押”。我对此一无所知,不知道应该使用哪些列或表来找到这个数字。我应该使用tx_hash还是tx_receiver?我完全困惑了。

运行此查询将根据分析的质押活动提供所提供数据库信息中不同验证器的数量。但我不认为这是正确的。

英文:

As you know the NEAR blockchain is based on Proof of stake protocol.the number of validators can be based on validators 'staking' or even 'not staking'. i'm new to this and i don't know which culoolumnsmns or tables should i use to find this number. should i use tx_hash or tx_reciever? i'm totally confused

WITH 
  staking AS (
    SELECT tx_hash
    FROM near.core.fact_actions_events_function_call
    WHERE method_name IN ('deposit_and_stake', 'stake', 'stake_all')
  ),
  stakes AS (
    SELECT 
      block_timestamp,
      tx_hash AS tx,
      tx_receiver AS validator, 
      tx_signer AS delegator,
      tx:actions[0]:FunctionCall:deposit/pow(10, 24) AS near_staked
    FROM near.core.fact_transactions
    WHERE tx_hash IN (SELECT * FROM staking)
  ),
  monthly AS (
    SELECT 
      trunc(block_timestamp, 'month') AS months,
      tx,
      validator,
      near_staked
    FROM stakes
    WHERE near_staked IS NOT NULL 
  ),
  totals AS (
    SELECT
      months,
      sum(near_staked) AS month_near_staked,
      sum(month_near_staked) OVER (ORDER BY months) AS total_near_staked
    FROM monthly
    GROUP BY 1
    ORDER BY 1
  ),
  ranking AS (
    SELECT 
      months,
      validator,
      count(DISTINCT tx) AS txs,
      sum(near_staked) AS total_near_delegated,
      sum(total_near_delegated) OVER (PARTITION BY validator ORDER BY months) AS cumulative_near_delegated
    FROM monthly 
    GROUP BY 1, 2
  )
SELECT COUNT(DISTINCT validator) AS num_validators
FROM ranking;

Running this query will provide the number of distinct validators present in the provided database information based on the staking activities analyzed. but i don't think it's true

答案1

得分: 1

Validators是网络中验证和验证新交易和区块的节点。验证器的数量通常不包含在与交易相关的数据中,比如tx_hash或tx_receiver。

要找到验证器的数量,您需要查看共识协议的详细信息以及当前验证器的列表,这可以从区块链数据中获取,但不能直接从单个交易数据中获取。

尝试这个链接,可能会有所帮助:

https://explorer.near.org/nodes/validators

如何使用SQL查询检索NEAR区块链上的验证器数量?

英文:

Validators are the nodes in the network that verify and validate new transactions and blocks. the number of validators is not typically found in transaction-related data such as tx_hash or tx_receiver.

To find the number of validators, you would need to look at the consensus protocol details and the list of current validators, it can be obtained from the blockchain data, but not directly from individual transaction data.

Try this, it might help ya:

https://explorer.near.org/nodes/validators

如何使用SQL查询检索NEAR区块链上的验证器数量?

huangapple
  • 本文由 发表于 2023年7月3日 04:00:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76600570.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定