diff --git a/.gitignore b/.gitignore index 487e7a2..c696239 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +etc bin flexassistant.yaml flexassistant.db \ No newline at end of file diff --git a/README.md b/README.md index 7a8cced..c6e62cc 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Reference: * `pools` (optional): list of pools * `coin`: coin of the pool (ex: `eth`, `xch`) * `enable-blocks` (optional): enable block notifications for this pool (disabled by default) + * `min-block-reward` (optional): send notifications when block reward has reached this minimum threshold in crypto currency unit (ETH, XCH, etc) * `miners` (optional): list of miners and/or farmers * `address`: address of the miner or the farmer registered on the API * `enable-balance` (optional): enable balance notifications (disabled by default) diff --git a/VERSION b/VERSION index c068b24..c239c60 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4 +1.5 diff --git a/config.go b/config.go index 6d3e7ab..692e1f6 100644 --- a/config.go +++ b/config.go @@ -19,8 +19,9 @@ type Config struct { // PoolConfig to store Pool configuration type PoolConfig struct { - Coin string `yaml:"coin"` - EnableBlocks bool `yaml:"enable-blocks"` + Coin string `yaml:"coin"` + EnableBlocks bool `yaml:"enable-blocks"` + MinBlockReward float64 `yaml:"min-block-reward"` } // MinerConfig to store Miner configuration diff --git a/flexassistant.yaml.example b/flexassistant.yaml.example index a4586d4..ea16ae6 100644 --- a/flexassistant.yaml.example +++ b/flexassistant.yaml.example @@ -14,8 +14,10 @@ miners: pools: - coin: eth enable-blocks: true + min-block-reward: 10 - coin: xch enable-blocks: true + min-block-reward: 1.79 telegram: chat-id: 000000000 channel-name: MyTelegramChannel diff --git a/main.go b/main.go index 6d426a5..5cbe58f 100644 --- a/main.go +++ b/main.go @@ -263,7 +263,11 @@ func main() { log.Warnf("Cannot update pool: %v", trx.Error) continue } - if notify { + convertedReward, err := ConvertCurrency(pool.Coin, block.Reward) + if err != nil { + log.Warnf("Reward for block %d cannot be converted: %v", block.Number, err) + } + if notify && convertedReward >= configuredPool.MinBlockReward { err = notifier.NotifyBlock(*pool, *block) if err != nil { log.Warnf("Cannot send notification: %v", err)