Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
feat: Minimum block rewards to send notifications
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jouir committed Feb 25, 2022
1 parent e3ae989 commit b519770
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
etc
bin
flexassistant.yaml
flexassistant.db
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4
1.5
5 changes: 3 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions flexassistant.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b519770

Please sign in to comment.