Update - modify hub to support multiple networks. (#4)
Co-authored-by: jdl <jdl@desktop> Reviewed-on: #4
This commit is contained in:
@@ -26,16 +26,9 @@ func Session_DeleteBefore(
|
||||
return err
|
||||
}
|
||||
|
||||
func Config_UpdatePassword(
|
||||
tx TX,
|
||||
pwdHash []byte,
|
||||
) (err error) {
|
||||
_, err = tx.Exec("UPDATE config SET Password=? WHERE ConfigID=1", pwdHash)
|
||||
return err
|
||||
}
|
||||
|
||||
func Peer_ListAll(tx TX) ([]*Peer, error) {
|
||||
return Peer_List(tx, Peer_SelectQuery)
|
||||
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) {
|
||||
@@ -45,7 +38,8 @@ func Peer_GetByAPIKey(tx TX, apiKey string) (*Peer, error) {
|
||||
apiKey)
|
||||
}
|
||||
|
||||
func Peer_Exists(tx TX, ip byte) (exists bool, err error) {
|
||||
err = tx.QueryRow(`SELECT EXISTS(SELECT 1 FROM peers WHERE PeerIP=?)`, ip).Scan(&exists)
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user