mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-23 03:59:25 +00:00
Follow the monero RPC response
This commit change database name and MoneroNode struct: - `NodeVersion` to `Version` - `LastHeight` to `Height` This commit also add `Status` to the MoneroNode struct.
This commit is contained in:
parent
8724b81431
commit
e9577b9bcf
4 changed files with 16 additions and 9 deletions
10
cmd/probe.go
10
cmd/probe.go
|
@ -162,6 +162,8 @@ func (p *proberClient) fetchNode(node repo.MoneroNode) (repo.MoneroNode, error)
|
|||
return node, err
|
||||
}
|
||||
|
||||
fmt.Println(string(body))
|
||||
|
||||
reportNode := struct {
|
||||
repo.MoneroNode `json:"result"`
|
||||
}{}
|
||||
|
@ -170,12 +172,16 @@ func (p *proberClient) fetchNode(node repo.MoneroNode) (repo.MoneroNode, error)
|
|||
// TODO: Post report to server
|
||||
return node, err
|
||||
}
|
||||
node.IsAvailable = true
|
||||
if reportNode.Status == "OK" {
|
||||
node.IsAvailable = true
|
||||
}
|
||||
node.NetType = reportNode.NetType
|
||||
node.AdjustedTime = reportNode.AdjustedTime
|
||||
node.DatabaseSize = reportNode.DatabaseSize
|
||||
node.Difficulty = reportNode.Difficulty
|
||||
node.NodeVersion = reportNode.NodeVersion
|
||||
node.Version = reportNode.Version
|
||||
|
||||
fmt.Println(prettyPrint(reportNode))
|
||||
|
||||
if resp.Header.Get("Access-Control-Allow-Origin") == "*" || resp.Header.Get("Access-Control-Allow-Origin") == "https://xmr.ditatompel.com" {
|
||||
node.CorsCapable = true
|
||||
|
|
|
@ -256,7 +256,7 @@
|
|||
port={row.port}
|
||||
/></td
|
||||
>
|
||||
<td><NetTypeCell nettype={row.nettype} height={row.last_height} /></td>
|
||||
<td><NetTypeCell nettype={row.nettype} height={row.height} /></td>
|
||||
<td><ProtocolCell protocol={row.protocol} cors={row.cors} /></td>
|
||||
<td
|
||||
><CountryCellWithAsn
|
||||
|
|
|
@ -37,11 +37,12 @@ type MoneroNode struct {
|
|||
IsTor bool `json:"is_tor" db:"is_tor"`
|
||||
IsAvailable bool `json:"is_available" db:"is_available"`
|
||||
NetType string `json:"nettype" db:"nettype"`
|
||||
LastHeight uint `json:"last_height" db:"last_height"`
|
||||
Height uint `json:"height" db:"height"`
|
||||
AdjustedTime uint `json:"adjusted_time" db:"adjusted_time"`
|
||||
DatabaseSize uint `json:"database_size" db:"database_size"`
|
||||
Difficulty uint `json:"difficulty" db:"difficulty"`
|
||||
NodeVersion string `json:"node_version" db:"node_version"`
|
||||
Version string `json:"version" db:"version"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Uptime float32 `json:"uptime" db:"uptime"`
|
||||
EstimateFee uint `json:"estimate_fee" db:"estimate_fee"`
|
||||
Asn uint `json:"asn" db:"asn"`
|
||||
|
@ -109,7 +110,7 @@ func (repo *MoneroRepo) Nodes(q MoneroQueryParams) (MoneroNodes, error) {
|
|||
sortDirection = "ASC"
|
||||
}
|
||||
|
||||
query := fmt.Sprintf("SELECT id, protocol, hostname, port, is_tor, is_available, nettype, last_height, adjusted_time, database_size, difficulty, node_version, uptime, estimate_fee, ip_addr, asn, asn_name, country, country_name, city, lat, lon, date_entered, last_checked, last_check_status, cors_capable FROM tbl_node %s ORDER BY %s %s LIMIT ? OFFSET ?", where, sortBy, sortDirection)
|
||||
query := fmt.Sprintf("SELECT id, protocol, hostname, port, is_tor, is_available, nettype, height, adjusted_time, database_size, difficulty, version, uptime, estimate_fee, ip_addr, asn, asn_name, country, country_name, city, lat, lon, date_entered, last_checked, last_check_status, cors_capable FROM tbl_node %s ORDER BY %s %s LIMIT ? OFFSET ?", where, sortBy, sortDirection)
|
||||
|
||||
row, err := repo.db.Query(query, queryParams...)
|
||||
if err != nil {
|
||||
|
@ -123,7 +124,7 @@ func (repo *MoneroRepo) Nodes(q MoneroQueryParams) (MoneroNodes, error) {
|
|||
|
||||
for row.Next() {
|
||||
node := MoneroNode{}
|
||||
err = row.Scan(&node.Id, &node.Protocol, &node.Hostname, &node.Port, &node.IsTor, &node.IsAvailable, &node.NetType, &node.LastHeight, &node.AdjustedTime, &node.DatabaseSize, &node.Difficulty, &node.NodeVersion, &node.Uptime, &node.EstimateFee, &node.Ip, &node.Asn, &node.AsnName, &node.CountryName, &node.CountryCode, &node.City, &node.Lat, &node.Lon, &node.DateEntered, &node.LastChecked, &node.LastCheckStatus, &node.CorsCapable)
|
||||
err = row.Scan(&node.Id, &node.Protocol, &node.Hostname, &node.Port, &node.IsTor, &node.IsAvailable, &node.NetType, &node.Height, &node.AdjustedTime, &node.DatabaseSize, &node.Difficulty, &node.Version, &node.Uptime, &node.EstimateFee, &node.Ip, &node.Asn, &node.AsnName, &node.CountryName, &node.CountryCode, &node.City, &node.Lat, &node.Lon, &node.DateEntered, &node.LastChecked, &node.LastCheckStatus, &node.CorsCapable)
|
||||
if err != nil {
|
||||
return nodes, err
|
||||
}
|
||||
|
|
|
@ -50,11 +50,11 @@ CREATE TABLE `tbl_node` (
|
|||
`is_tor` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||
`is_available` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||
`nettype` varchar(100) NOT NULL COMMENT 'mainnet | stagenet | testnet',
|
||||
`last_height` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`height` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`adjusted_time` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`database_size` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`difficulty` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`node_version` varchar(200) NOT NULL DEFAULT '',
|
||||
`version` varchar(200) NOT NULL,
|
||||
`uptime` float(5,2) unsigned NOT NULL DEFAULT 0.00,
|
||||
`estimate_fee` int(9) unsigned NOT NULL DEFAULT 0,
|
||||
`ip_addr` varchar(200) NOT NULL,
|
||||
|
|
Loading…
Reference in a new issue