feat: Minimum block rewards to send notifications
Flexpool is now finding more blocks than ever. There are tons of notifications all day long. This commit adds a new pool setting `min-block-reward` to send notifications for blocks reaching this minimum threshold, so we can focus on big blocks. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
e3ae989511
commit
b519770922
6 changed files with 13 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
etc
|
||||||
bin
|
bin
|
||||||
flexassistant.yaml
|
flexassistant.yaml
|
||||||
flexassistant.db
|
flexassistant.db
|
|
@ -73,6 +73,7 @@ Reference:
|
||||||
* `pools` (optional): list of pools
|
* `pools` (optional): list of pools
|
||||||
* `coin`: coin of the pool (ex: `eth`, `xch`)
|
* `coin`: coin of the pool (ex: `eth`, `xch`)
|
||||||
* `enable-blocks` (optional): enable block notifications for this pool (disabled by default)
|
* `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
|
* `miners` (optional): list of miners and/or farmers
|
||||||
* `address`: address of the miner or the farmer registered on the API
|
* `address`: address of the miner or the farmer registered on the API
|
||||||
* `enable-balance` (optional): enable balance notifications (disabled by default)
|
* `enable-balance` (optional): enable balance notifications (disabled by default)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.4
|
1.5
|
||||||
|
|
|
@ -19,8 +19,9 @@ type Config struct {
|
||||||
|
|
||||||
// PoolConfig to store Pool configuration
|
// PoolConfig to store Pool configuration
|
||||||
type PoolConfig struct {
|
type PoolConfig struct {
|
||||||
Coin string `yaml:"coin"`
|
Coin string `yaml:"coin"`
|
||||||
EnableBlocks bool `yaml:"enable-blocks"`
|
EnableBlocks bool `yaml:"enable-blocks"`
|
||||||
|
MinBlockReward float64 `yaml:"min-block-reward"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinerConfig to store Miner configuration
|
// MinerConfig to store Miner configuration
|
||||||
|
|
|
@ -14,8 +14,10 @@ miners:
|
||||||
pools:
|
pools:
|
||||||
- coin: eth
|
- coin: eth
|
||||||
enable-blocks: true
|
enable-blocks: true
|
||||||
|
min-block-reward: 10
|
||||||
- coin: xch
|
- coin: xch
|
||||||
enable-blocks: true
|
enable-blocks: true
|
||||||
|
min-block-reward: 1.79
|
||||||
telegram:
|
telegram:
|
||||||
chat-id: 000000000
|
chat-id: 000000000
|
||||||
channel-name: MyTelegramChannel
|
channel-name: MyTelegramChannel
|
||||||
|
|
6
main.go
6
main.go
|
@ -263,7 +263,11 @@ func main() {
|
||||||
log.Warnf("Cannot update pool: %v", trx.Error)
|
log.Warnf("Cannot update pool: %v", trx.Error)
|
||||||
continue
|
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)
|
err = notifier.NotifyBlock(*pool, *block)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Cannot send notification: %v", err)
|
log.Warnf("Cannot send notification: %v", err)
|
||||||
|
|
Reference in a new issue