mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-22 19:49:25 +00:00
refactor: Use slice.Contains()
nettype check
Instead using `||` for each nettype query check , simply using `slice.Contains`. Also, checking `any` value is not needed here.
This commit is contained in:
parent
cf77175210
commit
97fad6cacb
1 changed files with 3 additions and 5 deletions
|
@ -94,12 +94,10 @@ func (q QueryNodes) toSQL() (args []interface{}, where, sortBy, sortDirection st
|
|||
wq = append(wq, "(hostname LIKE ? OR ip_addr LIKE ?)")
|
||||
args = append(args, "%"+q.Host+"%", "%"+q.Host+"%")
|
||||
}
|
||||
if q.Nettype != "any" {
|
||||
if q.Nettype == "mainnet" || q.Nettype == "stagenet" || q.Nettype == "testnet" {
|
||||
if slices.Contains([]string{"mainnet", "stagenet", "testnet"}, q.Nettype) {
|
||||
wq = append(wq, "nettype = ?")
|
||||
args = append(args, q.Nettype)
|
||||
}
|
||||
}
|
||||
if q.Protocol != "any" && slices.Contains([]string{"tor", "http", "https"}, q.Protocol) {
|
||||
if q.Protocol == "tor" {
|
||||
wq = append(wq, "is_tor = ?")
|
||||
|
|
Loading…
Reference in a new issue