topology-foundation / topchain-node

MIT License
2 stars 3 forks source link

impr: Create a secondary mapping<dealRequester, deal[]> #16

Open h3lio5 opened 4 hours ago

h3lio5 commented 4 hours ago

Create a secondary mapping using the KVStore to avoid the following pagination query in x/subscription/keeper/query_deal.go:

var deals []types.Deal
pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error {
    var deal types.Deal
    if err := k.cdc.Unmarshal(value, &deal); err != nil {
        return err
    }

    if deal.Requester == req.Requester {
        deals = append(deals, deal)
    }

    return nil
})
sfroment commented 3 hours ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

:wave: already made the previous one for subscription, so will just do the same but for deal

sfroment commented 2 hours ago

@h3lio5 do you want a mapping exactly like in your title ? Or a store per deal requester that would point to each deal, like for the subscription ?