{
"alias" : "seed1",
"xpub" : "f2767279cd01ed8793808e0542a18958e1a2f3a6b6fe5328ec79596a022bc6f085951a98a631917563f86bb91db9159dd2969ff9d690fc12b250baff2b6f6a1d",
- "host": "47.103.79.68",
+ "ip": "47.103.79.68",
"port": 56656
},
{
"alias" : "seed2",
"xpub" : "c785deb76af14e918ea05eeab863288c48b16d1816621adf74ada868e8e3246780bf5206dc5a0e3efef0c119978e11ed75eca9d3b50846e37c55cf8d56717c4f",
- "host": "47.103.13.86",
+ "ip": "47.103.13.86",
"port": 56656
},
{
"alias" : "seed3",
"xpub" : "22bc19ec65d4ee524c5130575ddff041e712dbb415740eae314fd3359aa3978319384cd3ded8c4125ca2774716d7285268ebf1d85091eef8e7ad03077857e7ab",
- "host": "47.102.193.119",
+ "ip": "47.102.193.119",
"port": 56656
},
{
"alias" : "seed4",
"xpub" : "214c0e6827346e9fee1056c4c8b96cefd67b75ed1dead59e4e4e3eee8c1fe095dbe7a7fb61bb23b4ab66cde2a1c04466b8d3e8efa21cf7eee064c70fb1525b14",
- "host": "47.103.17.22",
+ "ip": "47.103.17.22",
"port": 56656
}
]
`alias` varchar(128) NOT NULL DEFAULT '',
`xpub` char(128) NOT NULL DEFAULT '',
`public_key` char(64) NOT NULL DEFAULT '',
- `host` varchar(128) NOT NULL DEFAULT '',
+ `ip` varchar(128) NOT NULL DEFAULT '',
`port` smallint unsigned NOT NULL DEFAULT '0',
`best_height` int(11) DEFAULT '0',
`latest_daily_uptime_minutes` int(11) DEFAULT '0',
Alias string `json:"alias"`
XPub *chainkd.XPub `json:"xpub"`
PublicKey string `json:"public_key"`
- Host string `json:"host"`
+ IP string `json:"ip"`
Port uint16 `json:"port"`
}
Alias string
Xpub string
PublicKey string
- Host string
+ IP string
Port uint16
BestHeight uint64
LatestDailyUptimeMinutes uint64
addresses := make([]*p2p.NetAddress, 0)
for i := 0; i < len(nodes); i++ {
- ips, err := net.LookupIP(nodes[i].Host)
- if err != nil {
- log.Error(err)
- continue
- }
- if len(ips) == 0 {
- log.Errorf("fail to look up ip for %s", nodes[i].Host)
- continue
- }
-
- address := p2p.NewNetAddressIPPort(ips[0], nodes[i].Port)
+ address := p2p.NewNetAddressIPPort(net.ParseIP(nodes[i].IP), nodes[i].Port)
addresses = append(addresses, address)
}
func (m *monitor) saveDiscoveredNode(node *dht.Node) {
if err := m.upSertNode(&config.Node{
PublicKey: node.ID.String(),
- Host: node.IP.String(),
+ IP: node.IP.String(),
Port: node.TCP,
}); err == nil {
m.discvMap[node.ID.String()] = node
func (m *monitor) Run() {
var seeds []string
for _, node := range m.cfg.Nodes {
- seeds = append(seeds, fmt.Sprintf("%s:%d", node.Host, node.Port))
+ seeds = append(seeds, fmt.Sprintf("%s:%d", node.IP, node.Port))
if err := m.upSertNode(&node); err != nil {
log.Error(err)
}
if node.XPub != nil {
ormNode.Xpub = node.XPub.String()
}
- ormNode.Host = node.Host
+ ormNode.IP = node.IP
ormNode.Port = node.Port
return m.db.Where(&orm.Node{PublicKey: ormNode.PublicKey}).
Assign(&orm.Node{
Xpub: ormNode.Xpub,
Alias: ormNode.Alias,
- Host: ormNode.Host,
+ IP: ormNode.IP,
Port: ormNode.Port,
}).FirstOrCreate(ormNode).Error
}