1 Star 0 Fork 12

Turbo/etherscan-api

forked from 楠木/etherscan-api 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
block.go 1013 Bytes
一键复制 编辑 原始数据 按行查看 历史
楠木 提交于 2021-10-15 14:31 . refactor: cleanup code
/*
* Copyright (c) 2018 LI Zhennan
*
* Use of this work is governed by a MIT License.
* You may find a license copy in project root.
*/
package etherscan
import (
"fmt"
"strconv"
)
// BlockReward gets block and uncle rewards by block number
func (c *Client) BlockReward(blockNum int) (rewards BlockRewards, err error) {
param := M{
"blockno": blockNum,
}
err = c.call("block", "getblockreward", param, &rewards)
return
}
// BlockNumber gets the closest block number by UNIX timestamp
//
// valid closest option: before, after
func (c *Client) BlockNumber(timestamp int64, closest string) (blockNumber int, err error) {
var blockNumberStr string
param := M{
"timestamp": strconv.FormatInt(timestamp, 10),
"closest": closest,
}
err = c.call("block", "getblocknobytime", param, &blockNumberStr)
if err != nil {
return
}
blockNumber, err = strconv.Atoi(blockNumberStr)
if err != nil {
err = fmt.Errorf("parsing block number %q: %w", blockNumberStr, err)
return
}
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/x-studio-wangqu/etherscan-api.git
git@gitee.com:x-studio-wangqu/etherscan-api.git
x-studio-wangqu
etherscan-api
etherscan-api
master

搜索帮助