forked from forbole/callisto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated staking pool values (forbole#455)
## Description Closes: [BDU-484](https://forbole.atlassian.net/browse/BDU-484) --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch - [x] provided a link to the relevant issue or specification - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
- Loading branch information
Showing
12 changed files
with
162 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package staking | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-co-op/gocron" | ||
"github.com/rs/zerolog/log" | ||
|
||
"github.com/forbole/bdjuno/v3/modules/utils" | ||
) | ||
|
||
// RegisterPeriodicOperations implements modules.PeriodicOperationsModule | ||
func (m *Module) RegisterPeriodicOperations(scheduler *gocron.Scheduler) error { | ||
log.Debug().Str("module", "staking").Msg("setting up periodic tasks") | ||
|
||
// Update the staking pool every 5 mins | ||
if _, err := scheduler.Every(5).Minutes().Do(func() { | ||
utils.WatchMethod(m.updateStakingPool) | ||
}); err != nil { | ||
return fmt.Errorf("error while scheduling staking pool periodic operation: %s", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// updateStakingPool reads from the LCD the current staking pool and stores its value inside the database | ||
func (m *Module) updateStakingPool() error { | ||
height, err := m.db.GetLastBlockHeight() | ||
if err != nil { | ||
return fmt.Errorf("error while getting latest block height: %s", err) | ||
} | ||
log.Debug().Str("module", "staking").Int64("height", height). | ||
Msg("updating staking pool") | ||
|
||
pool, err := m.GetStakingPool(height) | ||
if err != nil { | ||
return fmt.Errorf("error while getting staking pool: %s", err) | ||
|
||
} | ||
|
||
err = m.db.SaveStakingPool(pool) | ||
if err != nil { | ||
return fmt.Errorf("error while saving staking pool: %s", err) | ||
|
||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters