Skip to content

Commit

Permalink
initial logic to return light client attack evidence (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
andynog committed Jun 7, 2023
1 parent 14838e9 commit 778f632
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,30 @@ func (c *PostgresStorage) GetBlock(height int64) (ctypes.ResultBlock, error) {
}
}

// Retrieve light client attack evidences
lcaev := types.LightClientAttackEvidence{}
lcaevs, err := c.Connection.Query("SELECT "+
"common_height, "+
"total_voting_power, "+
"timestamp "+
"FROM comet.evidence_light_client_attack "+
"WHERE height=$1", height)
if err != nil {
return resultBlock, err
}
defer lcaevs.Close()
for lcaevs.Next() {
err := lcaevs.Scan(
&lcaev.CommonHeight,
&lcaev.TotalVotingPower,
&lcaev.Timestamp)
if err != nil {
return resultBlock, err
} else {
resultBlock.Block.Evidence.Evidence = append(resultBlock.Block.Evidence.Evidence, &lcaev)
}
}

return resultBlock, err
}

Expand Down

0 comments on commit 778f632

Please sign in to comment.