20 lines
557 B
Go
20 lines
557 B
Go
package db
|
|
|
|
func Peer_ListAll(tx TX, networkID int64) ([]*Peer, error) {
|
|
const query = Peer_SelectQuery + ` WHERE NetworkID=? ORDER BY PeerIP ASC`
|
|
return Peer_List(tx, query, networkID)
|
|
}
|
|
|
|
func Peer_GetByAPIKey(tx TX, apiKey string) (*Peer, error) {
|
|
return Peer_GetWhere(
|
|
tx,
|
|
Peer_SelectQuery+` WHERE APIKey=?`,
|
|
apiKey)
|
|
}
|
|
|
|
func Peer_Exists(tx TX, networkID int64, ip byte) (exists bool, err error) {
|
|
const query = `SELECT EXISTS(SELECT 1 FROM peers WHERE NetworkID=? AND PeerIP=?)`
|
|
err = tx.QueryRow(query, networkID, ip).Scan(&exists)
|
|
return
|
|
}
|