mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-23 03:59:25 +00:00
Delete monero node uptime <= 0% with > 300 records
This commit is contained in:
parent
8f5f972faf
commit
34e4d8c98d
1 changed files with 16 additions and 0 deletions
|
@ -319,6 +319,17 @@ func (repo *MoneroRepo) Add(protocol string, hostname string, port uint) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (repo *MoneroRepo) Delete(id uint) error {
|
||||
if _, err := repo.db.Exec(`DELETE FROM tbl_node WHERE id = ?`, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := repo.db.Exec(`DELETE FROM tbl_probe_log WHERE node_id = ?`, id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *MoneroRepo) GiveJob(acceptTor int) (MoneroNode, error) {
|
||||
queryParams := []interface{}{}
|
||||
whereQueries := []string{}
|
||||
|
@ -432,6 +443,11 @@ func (repo *MoneroRepo) ProcessJob(report ProbeReport, proberId int64) error {
|
|||
_, 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)
|
||||
|
||||
if avgUptime <= 0 && nodeStats.TotalFetched > 300 {
|
||||
fmt.Println("Deleting Monero node (0% uptime from > 300 records)")
|
||||
repo.Delete(report.NodeInfo.Id)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue