本文整理匯總了Golang中github.com/btcsuite/btcd/wire.NetAddress.Timestamp方法的典型用法代碼示例。如果您正苦於以下問題:Golang NetAddress.Timestamp方法的具體用法?Golang NetAddress.Timestamp怎麽用?Golang NetAddress.Timestamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/btcsuite/btcd/wire.NetAddress
的用法示例。
在下文中一共展示了NetAddress.Timestamp方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddAddressByIP
// AddAddressByIP adds an address where we are given an ip:port and not a
// wire.NetAddress.
func (a *AddrManager) AddAddressByIP(addrIP string) error {
// Split IP and port
addr, portStr, err := net.SplitHostPort(addrIP)
if err != nil {
return err
}
// Put it in wire.Netaddress
var na wire.NetAddress
na.Timestamp = time.Now()
na.IP = net.ParseIP(addr)
if na.IP == nil {
return fmt.Errorf("invalid ip address %s", addr)
}
port, err := strconv.ParseUint(portStr, 10, 0)
if err != nil {
return fmt.Errorf("invalid port %s: %v", portStr, err)
}
na.Port = uint16(port)
a.AddAddress(&na, &na) // XXX use correct src address
return nil
}