Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong index was used for sorting v2 delegation #192

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/indexer/db/client/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (indexerdbclient *IndexerDatabase) GetDelegations(

// Default sort by start_height for stable sorting
options := options.Find().SetSort(bson.D{
{Key: "start_height", Value: -1},
{Key: "btc_delegation_created_bbn_block.height", Value: -1},
{Key: "_id", Value: 1},
})

Expand All @@ -55,13 +55,13 @@ func (indexerdbclient *IndexerDatabase) GetDelegations(
filter = bson.M{
"$or": []bson.M{
{
"staker_btc_pk_hex": stakerPKHex,
"start_height": bson.M{"$lt": decodedToken.StartHeight},
"staker_btc_pk_hex": stakerPKHex,
"btc_delegation_created_bbn_block.height": bson.M{"$lt": decodedToken.StartHeight},
},
{
"staker_btc_pk_hex": stakerPKHex,
"start_height": decodedToken.StartHeight,
"_id": bson.M{"$gt": decodedToken.StakingTxHashHex},
"staker_btc_pk_hex": stakerPKHex,
"btc_delegation_created_bbn_block.height": decodedToken.StartHeight,
"_id": bson.M{"$gt": decodedToken.StakingTxHashHex},
},
},
}
Expand Down
Loading