eos ram价格计算 cpu net单位转换

eos的 ram cpu net 简介

eos区块链中,在界面上表现与其他区块链不同的是多出了,ram,cpu,net的显示,

ram

相当于存储空间,资产转账、智能合约的部署与执行都会占用区块链上的存储,所以在执行这些操作之前要保证自己又足够的ram,每次执行都会消耗ram。ram可以购买,卖出,买卖对象账户是eosio.ram。购买需要手续费0.5%,卖出需要手续费0.5%,这些手续费转入eosio.ramfee账户中。

cpu、net

执行转账、智能合约操作都需要消耗cpu、net,在电脑中执行程序也需要cpu,但是cpu、net消耗后会按时间段按百分比返还给用户。如果cpu、net用完了,可以等一段时间,系统会逐步返回这些资源。

ram价格计算 eos/kb

首先通过向nodeos节点开放的api请求市场信息

http://127.0.0.1:8888/v1/chain/get_table_rows

参数

{
	"scope":"eosio",
	"code":"eosio",
	"table":"rammarket",
	"json":true
}

返回

{
    "rows": [
        {
            "supply": "10000000000.0000 RAMCORE",
            "base": {
                "balance": "63646619759 RAM",
                "weight": "0.50000000000000000"
            },
            "quote": {
                "balance": "1079703.4785 SYS",
                "weight": "0.50000000000000000"
            }
        }
    ],
    "more": false
}

ram的价格=base.balance/quote.balance*1024(eos/kb)
63646619759/1079703.4785 * 1024 = 0.017371172(eos/kb)

获取用户ram cpu net 信息

请求api

http://127.0.0.1:8888/v1/chain/get_account

参数

{
	"account_name":"lwz"
}

返回

{
    "account_name": "lwz",
    "head_block_num": 2752932,
    "head_block_time": "2019-01-05T08:13:41.000",
    "privileged": false,
    "last_code_update": "1970-01-01T00:00:00.000",
    "created": "2018-12-20T06:16:56.000",
    "core_liquid_balance": "19976.0014 SYS",
    "ram_quota": 1340834870,
    "net_weight": "1000000000000",
    "cpu_weight": "1000000000000",
    "net_limit": {
        "used": 322,
        "available": "181137776466217",
        "max": "181137776466539"
    },
    "cpu_limit": {
        "used": 1171,
        "available": "34549288337472",
        "max": "34549288338643"
    },
    "ram_usage": 3686,
    "permissions": [
        {
            "perm_name": "active",
            "parent": "owner",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS6BBKKrRxsRarQk7sdK3wXAc9SMCbnmsWvF6rL27r3udxJJ7pmP",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        },
        {
            "perm_name": "owner",
            "parent": "",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS6BBKKrRxsRarQk7sdK3wXAc9SMCbnmsWvF6rL27r3udxJJ7pmP",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        }
    ],
    "total_resources": {
        "owner": "lwz",
        "net_weight": "100000000.0000 SYS",
        "cpu_weight": "100000000.0000 SYS",
        "ram_bytes": 1340834870
    },
    "self_delegated_bandwidth": {
        "from": "lwz",
        "to": "lwz",
        "net_weight": "100000000.0000 SYS",
        "cpu_weight": "100000000.0000 SYS"
    },
    "refund_request": null,
    "voter_info": {
        "owner": "lwz",
        "proxy": "",
        "producers": [],
        "staked": "2000000000000",
        "last_vote_weight": "0.00000000000000000",
        "proxied_vote_weight": "0.00000000000000000",
        "is_proxy": 0
    }
}

其中有用的参数是

{
    "ram_quota": 1340834870,
    "net_limit": {
        "used": 322,
        "available": "181137776466217",
        "max": "181137776466539"
    },
    "cpu_limit": {
        "used": 1171,
        "available": "34549288337472",
        "max": "34549288338643"
    },
    "ram_usage": 3686
}

ram换算

查询结果单位为byte,也就是1340834870byte
按照通常存储计算,byte=Kb/1024=Mb/1024/1024=Gb/1024/1024/1024
1340834870/1024/1024/1024 = 1.248749783Gb

net换算

查询结果单位为byte,有就是181137776466217byte
net的单位为byte,Kb,Mb,Gb表示
按照通常带宽计算,byte=Kb/1024=Mb/1024/1024=Gb/1024/1024/1024=Tb/1024/1024/1024/1024
181137776466217/1024/1024/1024/1024 = 164.743848Tb

cpu换算

查询结果单位为us(微秒),也就是34549288337472
cpu的单位为ms,s
界面显示为:34549288337472us
换算成hr(小时):
34549288337472/1000/1000/60/60 = 9597.024538hr

换算结果通过命令行验证

执行命令

cleos --wallet-url http://192.168.10.11:8900 -u http://192.168.10.11:8888 get account lwz

返回信息

created: 2018-12-20T06:16:56.000
permissions: 
     owner     1:    1 EOS6BBKKrRxsRarQk7sdK3wXAc9SMCbnmsWvF6rL27r3udxJJ7pmP
        active     1:    1 EOS6BBKKrRxsRarQk7sdK3wXAc9SMCbnmsWvF6rL27r3udxJJ7pmP
memory: 
     quota:     1.249 GiB    used:       3.6 KiB  

net bandwidth: 
     staked:  100000000.0000 SYS           (total stake delegated from account to self)
     delegated:       0.0000 SYS           (total staked delegated to account from others)
     used:               322 bytes
     available:        164.7 TiB  
     limit:            164.7 TiB  

cpu bandwidth:
     staked:  100000000.0000 SYS           (total stake delegated from account to self)
     delegated:       0.0000 SYS           (total staked delegated to account from others)
     used:             1.171 ms   
     available:         9597 hr   
     limit:             9597 hr   

SYS balances: 
     liquid:        19976.0014 SYS
     staked:    200000000.0000 SYS
     unstaking:         0.0000 SYS
     total:     200019976.0014 SYS

producers:     <not voted>

对换算的结果可通过命令行进行验证

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值