mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
docs: Add handler function info
This commit is contained in:
parent
e01c28d966
commit
d9017a47b9
1 changed files with 15 additions and 2 deletions
|
@ -75,6 +75,9 @@ func Nodes(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns probe logs reported by nodes
|
||||||
|
//
|
||||||
|
// The embadded web UI use `node_id` query param to filter logs
|
||||||
func ProbeLogs(c *fiber.Ctx) error {
|
func ProbeLogs(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.New()
|
moneroRepo := monero.New()
|
||||||
query := monero.QueryLogs{
|
query := monero.QueryLogs{
|
||||||
|
@ -103,6 +106,7 @@ func ProbeLogs(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handles `POST /nodes` request to add a new node
|
||||||
func AddNode(c *fiber.Ctx) error {
|
func AddNode(c *fiber.Ctx) error {
|
||||||
formPort := c.FormValue("port")
|
formPort := c.FormValue("port")
|
||||||
port, err := strconv.Atoi(formPort)
|
port, err := strconv.Atoi(formPort)
|
||||||
|
@ -133,6 +137,7 @@ func AddNode(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns majority network fees
|
||||||
func NetFees(c *fiber.Ctx) error {
|
func NetFees(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.New()
|
moneroRepo := monero.New()
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
|
@ -142,6 +147,7 @@ func NetFees(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns list of countries (count by nodes)
|
||||||
func Countries(c *fiber.Ctx) error {
|
func Countries(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.New()
|
moneroRepo := monero.New()
|
||||||
countries, err := moneroRepo.Countries()
|
countries, err := moneroRepo.Countries()
|
||||||
|
@ -159,6 +165,9 @@ func Countries(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns node to be probed by the client (prober)
|
||||||
|
//
|
||||||
|
// This handler should protected by `CheckProber` middleware.
|
||||||
func GiveJob(c *fiber.Ctx) error {
|
func GiveJob(c *fiber.Ctx) error {
|
||||||
acceptTor := c.QueryInt("accept_tor", 0)
|
acceptTor := c.QueryInt("accept_tor", 0)
|
||||||
|
|
||||||
|
@ -179,9 +188,11 @@ func GiveJob(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handles probe report submission by the prober
|
||||||
|
//
|
||||||
|
// This handler should protected by `CheckProber` middleware.
|
||||||
func ProcessJob(c *fiber.Ctx) error {
|
func ProcessJob(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.New()
|
var report monero.ProbeReport
|
||||||
report := monero.ProbeReport{}
|
|
||||||
|
|
||||||
if err := c.BodyParser(&report); err != nil {
|
if err := c.BodyParser(&report); err != nil {
|
||||||
return c.Status(fiber.StatusUnprocessableEntity).JSON(fiber.Map{
|
return c.Status(fiber.StatusUnprocessableEntity).JSON(fiber.Map{
|
||||||
|
@ -191,6 +202,8 @@ func ProcessJob(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moneroRepo := monero.New()
|
||||||
|
|
||||||
if err := moneroRepo.ProcessJob(report, c.Locals("prober_id").(int64)); err != nil {
|
if err := moneroRepo.ProcessJob(report, c.Locals("prober_id").(int64)); err != nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
"status": "error",
|
"status": "error",
|
||||||
|
|
Loading…
Reference in a new issue