Skip to content

Commit

Permalink
stores: create consensus info in ChainIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl authored and n8maninger committed Jul 15, 2024
1 parent f1cee0d commit 0c50b3b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stores/sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,11 @@ func Tip(ctx context.Context, tx sql.Tx) (types.ChainIndex, error) {
var id Hash256
var height uint64
if err := tx.QueryRow(ctx, "SELECT height, block_id FROM consensus_infos WHERE id = ?", sql.ConsensusInfoID).
Scan(&id, &height); err != nil {
Scan(&height, &id); errors.Is(err, dsql.ErrNoRows) {
// init
_, err = tx.Exec(ctx, "INSERT INTO consensus_infos (id, height, block_id) VALUES (?, ?, ?)", sql.ConsensusInfoID, 0, Hash256{})
return types.ChainIndex{}, err
} else if err != nil {
return types.ChainIndex{}, err
}
return types.ChainIndex{
Expand Down

0 comments on commit 0c50b3b

Please sign in to comment.