Keep nettype, height, etc same as before

Do not replace existing database record if prober can't reach the remote
nodes. Only update node status and last fetch record.
This commit is contained in:
Cristian Ditaputratama 2024-05-08 19:03:41 +07:00
parent cf9fa9097a
commit f931066c8c
Signed by: ditatompel
GPG key ID: 31D3D06D77950979

View file

@ -455,16 +455,20 @@ func (repo *MoneroRepo) ProcessJob(report ProbeReport, proberId int64) error {
} }
} }
update := `UPDATE tbl_node SET if report.NodeInfo.IsAvailable {
update := `UPDATE tbl_node SET
is_available = ?, nettype = ?, height = ?, adjusted_time = ?, is_available = ?, nettype = ?, height = ?, adjusted_time = ?,
database_size = ?, difficulty = ?, version = ?, uptime = ?, database_size = ?, difficulty = ?, version = ?, uptime = ?,
estimate_fee = ?, ip_addr = ?, asn = ?, asn_name = ?, country = ?, estimate_fee = ?, ip_addr = ?, asn = ?, asn_name = ?, country = ?,
country_name = ?, city = ?, last_checked = ?, last_check_status = ?, country_name = ?, city = ?, last_checked = ?, last_check_status = ?,
cors_capable = ? cors_capable = ?
WHERE id = ?` WHERE id = ?`
_, err = repo.db.Exec(update,
_, err = repo.db.Exec(update, nodeAvailable, report.NodeInfo.NetType, report.NodeInfo.Height, report.NodeInfo.AdjustedTime, report.NodeInfo.DatabaseSize, report.NodeInfo.Difficulty, report.NodeInfo.Version, report.NodeInfo.Uptime, report.NodeInfo.EstimateFee, report.NodeInfo.Ip, report.NodeInfo.Asn, report.NodeInfo.AsnName, report.NodeInfo.CountryCode, report.NodeInfo.CountryName, report.NodeInfo.City, now.Unix(), string(statuesValueToDb), report.NodeInfo.CorsCapable, report.NodeInfo.Id)
nodeAvailable, report.NodeInfo.NetType, report.NodeInfo.Height, report.NodeInfo.AdjustedTime, report.NodeInfo.DatabaseSize, report.NodeInfo.Difficulty, report.NodeInfo.Version, report.NodeInfo.Uptime, report.NodeInfo.EstimateFee, report.NodeInfo.Ip, report.NodeInfo.Asn, report.NodeInfo.AsnName, report.NodeInfo.CountryCode, report.NodeInfo.CountryName, report.NodeInfo.City, now.Unix(), string(statuesValueToDb), report.NodeInfo.CorsCapable, report.NodeInfo.Id) } else {
update := `UPDATE tbl_node SET is_available = ?, uptime = ?, last_checked = ?, last_check_status = ? WHERE id = ?`
_, err = repo.db.Exec(update, nodeAvailable, report.NodeInfo.Uptime, now.Unix(), string(statuesValueToDb), report.NodeInfo.Id)
}
if avgUptime <= 0 && nodeStats.TotalFetched > 300 { if avgUptime <= 0 && nodeStats.TotalFetched > 300 {
fmt.Println("Deleting Monero node (0% uptime from > 300 records)") fmt.Println("Deleting Monero node (0% uptime from > 300 records)")