代码拉取完成,页面将自动刷新
同步操作将从 楠木/etherscan-api 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* 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 (
"math/big"
"reflect"
"strconv"
"time"
)
// compose adds input to param, whose key is tag
// if input is nil or nil of some type, compose is a no-op.
func compose(param map[string]interface{}, tag string, input interface{}) {
// simple situation
if input == nil {
return
}
// needs dig further
v := reflect.ValueOf(input)
switch v.Kind() {
case reflect.Ptr, reflect.Slice, reflect.Interface:
if v.IsNil() {
return
}
}
param[tag] = input
}
// M is a type shorthand for param input
type M map[string]interface{}
// BigInt is a wrapper over big.Int to implement only unmarshalText
// for json decoding.
type BigInt big.Int
// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (b *BigInt) UnmarshalText(text []byte) (err error) {
var bigInt = new(big.Int)
err = bigInt.UnmarshalText(text)
if err != nil {
return
}
*b = BigInt(*bigInt)
return nil
}
// MarshalText implements the encoding.TextMarshaler
func (b *BigInt) MarshalText() (text []byte, err error) {
return []byte(b.Int().String()), nil
}
// Int returns b's *big.Int form
func (b *BigInt) Int() *big.Int {
return (*big.Int)(b)
}
// Time is a wrapper over big.Int to implement only unmarshalText
// for json decoding.
type Time time.Time
// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (t *Time) UnmarshalText(text []byte) (err error) {
input, err := strconv.ParseInt(string(text), 10, 64)
if err != nil {
err = wrapErr(err, "strconv.ParseInt")
return
}
var timestamp = time.Unix(input, 0)
*t = Time(timestamp)
return nil
}
// Time returns t's time.Time form
func (t Time) Time() time.Time {
return time.Time(t)
}
// MarshalText implements the encoding.TextMarshaler
func (t Time) MarshalText() (text []byte, err error) {
return []byte(strconv.FormatInt(t.Time().Unix(), 10)), nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。