go-waku/waku/v2/rpc/debug.go

42 lines
897 B
Go
Raw Normal View History

package rpc
import (
2022-06-19 21:47:39 +00:00
"fmt"
"net/http"
"github.com/waku-org/go-waku/waku/v2/node"
)
type DebugService struct {
node *node.WakuNode
}
type InfoArgs struct {
}
type InfoReply struct {
2022-06-13 18:30:35 +00:00
ENRUri string `json:"enrUri,omitempty"`
ListenAddresses []string `json:"listenAddresses,omitempty"`
}
func NewDebugService(node *node.WakuNode) *DebugService {
return &DebugService{
2022-08-09 14:15:16 +00:00
node: node,
}
}
func (d *DebugService) GetV1Info(r *http.Request, args *InfoArgs, reply *InfoReply) error {
2022-06-13 18:30:35 +00:00
reply.ENRUri = d.node.ENR().String()
for _, addr := range d.node.ListenAddresses() {
reply.ListenAddresses = append(reply.ListenAddresses, addr.String())
}
return nil
}
type VersionResponse string
func (d *DebugService) GetV1Version(r *http.Request, args *InfoArgs, reply *VersionResponse) error {
2022-08-09 14:15:16 +00:00
*reply = VersionResponse(fmt.Sprintf("%s-%s", node.Version, node.GitCommit))
return nil
}