mirror of https://github.com/status-im/go-waku.git
fix: get peers api to not include own node ID as peer (#974)
This commit is contained in:
parent
b5068b4357
commit
bad57fcb0c
|
@ -62,6 +62,10 @@ func (a *AdminService) getV1Peers(w http.ResponseWriter, req *http.Request) {
|
|||
|
||||
response := make([]WakuPeer, 0)
|
||||
for _, peer := range peers {
|
||||
if peer.ID.String() == a.node.Host().ID().String() {
|
||||
//Skip own node id
|
||||
continue
|
||||
}
|
||||
wPeer := WakuPeer{
|
||||
ID: peer.ID.Pretty(),
|
||||
Connected: peer.Connected,
|
||||
|
|
|
@ -57,6 +57,10 @@ func (a *AdminService) GetV1Peers(req *http.Request, args *GetPeersArgs, reply *
|
|||
return nil
|
||||
}
|
||||
for _, peer := range peers {
|
||||
if peer.ID.String() == a.node.Host().ID().String() {
|
||||
//Skip own node id
|
||||
continue
|
||||
}
|
||||
for _, addr := range peer.Addrs {
|
||||
for _, proto := range peer.Protocols {
|
||||
if !server.IsWakuProtocol(proto) {
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/avast/retry-go/v4"
|
||||
)
|
||||
|
||||
var dbUrlTemplate = "postgres://postgres@localhost:%s/%s?sslmode=disable"
|
||||
|
@ -39,8 +41,16 @@ func NewMockPgDB() *sql.DB {
|
|||
mockPgDBPort = "5432"
|
||||
}
|
||||
//
|
||||
err := retry.Do(
|
||||
func() error {
|
||||
|
||||
dropDBUrl := fmt.Sprintf(dbUrlTemplate, mockPgDBPort, "template1")
|
||||
if err := ResetDefaultTestPostgresDB(dropDBUrl); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}, retry.Attempts(3))
|
||||
if err != nil {
|
||||
log.Fatalf("an error '%s' while reseting the db", err)
|
||||
}
|
||||
mockDBUrl := fmt.Sprintf(dbUrlTemplate, mockPgDBPort, "postgres")
|
||||
|
|
Loading…
Reference in New Issue