feat: ETC support and notifications tests
- Add ETC to the list of supported coins. A new `coin` setting can be configured to avoid conflict with `eth`. Mind the lowercase. By default, flexassitant will try to deduce the coin from the miner's address (with eth by default, not etc). (#5) - Add `test` (true/false) to `notifications` section to test notifications with random values fetched from the Flexpool API - Fix typo in the configuration example (#6) BREAKING CHANGE: `notification-templates` configuration settings have been renamed to `notifications`, with sections to configure balance, payment, block and offline workers notifications, with `template` and `test` settings. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
b519770922
commit
d2d1503779
8 changed files with 289 additions and 53 deletions
16
main.go
16
main.go
|
|
@ -3,7 +3,9 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
|
|
@ -30,6 +32,7 @@ const MaxBlocks = 50
|
|||
// initialize logging
|
||||
func init() {
|
||||
log.SetOutput(os.Stdout)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
@ -84,11 +87,20 @@ func main() {
|
|||
client := NewFlexpoolClient()
|
||||
|
||||
// Notifications
|
||||
notifier, err := NewTelegramNotifier(&config.TelegramConfig, &config.NotificationTemplates)
|
||||
notifier, err := NewTelegramNotifier(&config.TelegramConfig, &config.Notifications)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not create notifier: %v", err)
|
||||
}
|
||||
|
||||
executed, err := notifier.NotifyTest(*client)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not send test notifications: %v", err)
|
||||
}
|
||||
if executed {
|
||||
log.Debug("Exit after sending test notifications")
|
||||
return
|
||||
}
|
||||
|
||||
// Limits
|
||||
var maxPayments int
|
||||
if config.MaxPayments > 0 {
|
||||
|
|
@ -106,7 +118,7 @@ func main() {
|
|||
|
||||
// Handle miners
|
||||
for _, configuredMiner := range config.Miners {
|
||||
miner, err := NewMiner(configuredMiner.Address)
|
||||
miner, err := NewMiner(configuredMiner.Address, configuredMiner.Coin)
|
||||
if err != nil {
|
||||
log.Warnf("Could not parse miner: %v", err)
|
||||
continue
|
||||
|
|
|
|||
Reference in a new issue