mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-22 19:49:25 +00:00
Lowercase & upperase initialism acronyms
See https://google.github.io/styleguide/go/decisions#initialisms
This commit is contained in:
parent
5f5ebd81a9
commit
cd52dc7b70
4 changed files with 13 additions and 13 deletions
|
@ -68,8 +68,8 @@ xmr-nodes probers list -s last_submit_ts -d asc sin1`,
|
||||||
fmt.Fprintf(w, "%d\t| %s\t| %s\t| %s\n",
|
fmt.Fprintf(w, "%d\t| %s\t| %s\t| %s\n",
|
||||||
prober.ID,
|
prober.ID,
|
||||||
prober.Name,
|
prober.Name,
|
||||||
time.Unix(prober.LastSubmitTs, 0).Format(time.RFC3339),
|
time.Unix(prober.LastSubmitTS, 0).Format(time.RFC3339),
|
||||||
prober.ApiKey,
|
prober.APIKey,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
@ -115,7 +115,7 @@ This command will display the prober name and API key when successfully executed
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Name: %s\nAPI Key: %s\n", prober.Name, prober.ApiKey)
|
fmt.Printf("Name: %s\nAPI Key: %s\n", prober.Name, prober.APIKey)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ func CheckProber(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
prober, err := monero.NewProber().CheckApi(key)
|
prober, err := monero.NewProber().CheckAPI(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||||
"status": "error",
|
"status": "error",
|
||||||
|
|
|
@ -15,7 +15,7 @@ type ProberRepository interface {
|
||||||
Add(name string) (Prober, error)
|
Add(name string) (Prober, error)
|
||||||
Edit(id int, name string) error
|
Edit(id int, name string) error
|
||||||
Probers(QueryProbers) ([]Prober, error)
|
Probers(QueryProbers) ([]Prober, error)
|
||||||
CheckApi(key string) (Prober, error)
|
CheckAPI(key string) (Prober, error)
|
||||||
Delete(id int) error
|
Delete(id int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ type ProberRepo struct {
|
||||||
type Prober struct {
|
type Prober struct {
|
||||||
ID int64 `json:"id" db:"id"`
|
ID int64 `json:"id" db:"id"`
|
||||||
Name string `json:"name" db:"name"`
|
Name string `json:"name" db:"name"`
|
||||||
ApiKey uuid.UUID `json:"api_key" db:"api_key"`
|
APIKey uuid.UUID `json:"api_key" db:"api_key"`
|
||||||
LastSubmitTs int64 `json:"last_submit_ts" db:"last_submit_ts"`
|
LastSubmitTS int64 `json:"last_submit_ts" db:"last_submit_ts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes a new ProberRepository
|
// Initializes a new ProberRepository
|
||||||
|
@ -54,7 +54,7 @@ func (r *ProberRepo) Add(name string) (Prober, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Prober{}, err
|
return Prober{}, err
|
||||||
}
|
}
|
||||||
return Prober{Name: name, ApiKey: apiKey}, nil
|
return Prober{Name: name, APIKey: apiKey}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit an existing prober
|
// Edit an existing prober
|
||||||
|
@ -143,7 +143,7 @@ func (r *ProberRepo) Probers(q QueryProbers) ([]Prober, error) {
|
||||||
|
|
||||||
for row.Next() {
|
for row.Next() {
|
||||||
var p Prober
|
var p Prober
|
||||||
err = row.Scan(&p.ID, &p.Name, &p.ApiKey, &p.LastSubmitTs)
|
err = row.Scan(&p.ID, &p.Name, &p.APIKey, &p.LastSubmitTS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probers, err
|
return probers, err
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ func (r *ProberRepo) Probers(q QueryProbers) ([]Prober, error) {
|
||||||
return probers, nil
|
return probers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ProberRepo) CheckApi(key string) (Prober, error) {
|
func (r *ProberRepo) CheckAPI(key string) (Prober, error) {
|
||||||
var p Prober
|
var p Prober
|
||||||
query := `
|
query := `
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -165,6 +165,6 @@ func (r *ProberRepo) CheckApi(key string) (Prober, error) {
|
||||||
WHERE
|
WHERE
|
||||||
api_key = ?
|
api_key = ?
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
err := r.db.QueryRow(query, key).Scan(&p.ID, &p.Name, &p.ApiKey, &p.LastSubmitTs)
|
err := r.db.QueryRow(query, key).Scan(&p.ID, &p.Name, &p.APIKey, &p.LastSubmitTS)
|
||||||
return p, err
|
return p, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ func TestProberRepo_CheckApi(t *testing.T) {
|
||||||
repo := NewProber()
|
repo := NewProber()
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
_, err := repo.CheckApi(tt.apiKey)
|
_, err := repo.CheckAPI(tt.apiKey)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Errorf("ProberRepo.CheckApi() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("ProberRepo.CheckApi() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
|
@ -143,6 +143,6 @@ func BenchmarkProberRepo_CheckApi(b *testing.B) {
|
||||||
}
|
}
|
||||||
repo := NewProber()
|
repo := NewProber()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
repo.CheckApi("")
|
repo.CheckAPI("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue