mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-18 16:54:33 +00:00
Rename NewMoneroRepo
to just New
Just run `monero.New()` to initialize MoneroRepository. The database connection is now called from the `New()` function
This commit is contained in:
parent
99a367f04b
commit
6b5225758e
2 changed files with 10 additions and 11 deletions
|
@ -2,7 +2,6 @@ package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"xmr-remote-nodes/internal/database"
|
|
||||||
"xmr-remote-nodes/internal/monero"
|
"xmr-remote-nodes/internal/monero"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
@ -26,7 +25,7 @@ func MoneroNode(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
node, err := moneroRepo.Node(nodeId)
|
node, err := moneroRepo.Node(nodeId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
|
@ -44,7 +43,7 @@ func MoneroNode(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoneroNodes(c *fiber.Ctx) error {
|
func MoneroNodes(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
query := monero.QueryNodes{
|
query := monero.QueryNodes{
|
||||||
RowsPerPage: c.QueryInt("limit", 10),
|
RowsPerPage: c.QueryInt("limit", 10),
|
||||||
Page: c.QueryInt("page", 1),
|
Page: c.QueryInt("page", 1),
|
||||||
|
@ -75,7 +74,7 @@ func MoneroNodes(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProbeLogs(c *fiber.Ctx) error {
|
func ProbeLogs(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
query := monero.MoneroLogQueryParams{
|
query := monero.MoneroLogQueryParams{
|
||||||
RowsPerPage: c.QueryInt("limit", 10),
|
RowsPerPage: c.QueryInt("limit", 10),
|
||||||
Page: c.QueryInt("page", 1),
|
Page: c.QueryInt("page", 1),
|
||||||
|
@ -116,7 +115,7 @@ func AddNode(c *fiber.Ctx) error {
|
||||||
protocol := c.FormValue("protocol")
|
protocol := c.FormValue("protocol")
|
||||||
hostname := c.FormValue("hostname")
|
hostname := c.FormValue("hostname")
|
||||||
|
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
if err := moneroRepo.Add(protocol, hostname, uint(port)); err != nil {
|
if err := moneroRepo.Add(protocol, hostname, uint(port)); err != nil {
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
"status": "error",
|
"status": "error",
|
||||||
|
@ -133,7 +132,7 @@ func AddNode(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NetFee(c *fiber.Ctx) error {
|
func NetFee(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
"message": "Success",
|
"message": "Success",
|
||||||
|
@ -142,7 +141,7 @@ func NetFee(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Countries(c *fiber.Ctx) error {
|
func Countries(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
countries, err := moneroRepo.Countries()
|
countries, err := moneroRepo.Countries()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
|
@ -161,7 +160,7 @@ func Countries(c *fiber.Ctx) error {
|
||||||
func GiveJob(c *fiber.Ctx) error {
|
func GiveJob(c *fiber.Ctx) error {
|
||||||
acceptTor := c.QueryInt("accept_tor", 0)
|
acceptTor := c.QueryInt("accept_tor", 0)
|
||||||
|
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
node, err := moneroRepo.GiveJob(acceptTor)
|
node, err := moneroRepo.GiveJob(acceptTor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
|
@ -179,7 +178,7 @@ func GiveJob(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcessJob(c *fiber.Ctx) error {
|
func ProcessJob(c *fiber.Ctx) error {
|
||||||
moneroRepo := monero.NewMoneroRepo(database.GetDB())
|
moneroRepo := monero.New()
|
||||||
report := monero.ProbeReport{}
|
report := monero.ProbeReport{}
|
||||||
|
|
||||||
if err := c.BodyParser(&report); err != nil {
|
if err := c.BodyParser(&report); err != nil {
|
||||||
|
|
|
@ -32,8 +32,8 @@ type MoneroRepo struct {
|
||||||
db *database.DB
|
db *database.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMoneroRepo(db *database.DB) MoneroRepository {
|
func New() MoneroRepository {
|
||||||
return &MoneroRepo{db}
|
return &MoneroRepo{db: database.GetDB()}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Node represents a single remote node
|
// Node represents a single remote node
|
||||||
|
|
Loading…
Reference in a new issue