Skip to content

Commit

Permalink
Merge pull request #79 from cosmos-gaminghub/fix/issue
Browse files Browse the repository at this point in the history
Fix sync missed block
  • Loading branch information
EG-easy authored Mar 1, 2022
2 parents b806f81 + bbfeed7 commit 81124c9
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions exporter/missed_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,36 @@ func SaveMissedBlock(clientHTTP *rpchttp.HTTP, height int64, block *schema.Block
fmt.Println(err.Error())
}

for _, event := range result.BeginBlockEvents {
if event.Type == "liveness" {
var consensusAddress, eventHeight string
var insertHeight int64
for _, v := range event.GetAttributes() {
if result != nil {
for _, event := range result.BeginBlockEvents {
if event.Type == "liveness" {
var consensusAddress, eventHeight string
var insertHeight int64
for _, v := range event.GetAttributes() {

var ak = bytes.NewBuffer(v.GetKey()).String()
if ak == "address" {
consensusAddress = bytes.NewBuffer(v.GetValue()).String()
}
var ak = bytes.NewBuffer(v.GetKey()).String()
if ak == "address" {
consensusAddress = bytes.NewBuffer(v.GetValue()).String()
}

if ak == "height" {
eventHeight = bytes.NewBuffer(v.GetValue()).String()
insertHeight, _ = strconv.ParseInt(eventHeight, 10, 64)
if err != nil {
logger.Error(fmt.Sprintf("[Missed block] failed to parse string %s to int64", eventHeight))
if ak == "height" {
eventHeight = bytes.NewBuffer(v.GetValue()).String()
insertHeight, _ = strconv.ParseInt(eventHeight, 10, 64)
if err != nil {
logger.Error(fmt.Sprintf("[Missed block] failed to parse string %s to int64", eventHeight))
}
}
if insertHeight > 0 {
b := schema.NewMissedBlock(schema.MissedBlock{
Height: insertHeight,
ConsensusAddress: consensusAddress,
Timestamp: block.Timestamp,
})
orm.Save("missed_block", b)
}
}
if insertHeight > 0 {
b := schema.NewMissedBlock(schema.MissedBlock{
Height: insertHeight,
ConsensusAddress: consensusAddress,
Timestamp: block.Timestamp,
})
orm.Save("missed_block", b)
}
}
}
}

}

0 comments on commit 81124c9

Please sign in to comment.