-
Notifications
You must be signed in to change notification settings - Fork 0
/
handle_block.go
35 lines (27 loc) · 932 Bytes
/
handle_block.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package slashing
import (
"fmt"
juno "github.com/forbole/juno/v4/types"
"github.com/rs/zerolog/log"
tmctypes "github.com/tendermint/tendermint/rpc/core/types"
)
// HandleBlock implements BlockModule
func (m *Module) HandleBlock(
block *tmctypes.ResultBlock, results *tmctypes.ResultBlockResults, _ []*juno.Tx, _ *tmctypes.ResultValidators,
) error {
// Update the signing infos
err := m.updateSigningInfo(block.Block.Height)
if err != nil {
return fmt.Errorf("error while updating signing info: %s", err)
}
return nil
}
// updateSigningInfo reads from the LCD the current staking pool and stores its value inside the database
func (m *Module) updateSigningInfo(height int64) error {
log.Debug().Str("module", "slashing").Int64("height", height).Msg("updating signing info")
signingInfos, err := m.getSigningInfos(height)
if err != nil {
return err
}
return m.db.SaveValidatorsSigningInfos(signingInfos)
}