mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-04-30 12:41:59 +08:00
fix: not found error
This commit is contained in:
@@ -35,7 +35,7 @@ type RunesReaderDataGateway interface {
|
||||
// Cannot use []byte as map key, so we're returning as slice.
|
||||
GetBalancesByRuneId(ctx context.Context, runeId runes.RuneId, blockHeight uint64) ([]*entity.Balance, error)
|
||||
// GetBalancesByPkScriptAndRuneId returns the balance for the given pkScript and runeId at the given blockHeight.
|
||||
GetBalancesByPkScriptAndRuneId(ctx context.Context, pkScript []byte, runeId runes.RuneId, blockHeight uint64) (*entity.Balance, error)
|
||||
GetBalanceByPkScriptAndRuneId(ctx context.Context, pkScript []byte, runeId runes.RuneId, blockHeight uint64) (*entity.Balance, error)
|
||||
}
|
||||
|
||||
type RunesWriterDataGateway interface {
|
||||
|
||||
@@ -360,8 +360,11 @@ func (p *Processor) getTxInputsPkScripts(ctx context.Context, tx *types.Transact
|
||||
func (p *Processor) updateNewBalances(ctx context.Context, tx *types.Transaction, txInputsPkScripts map[int][]byte, inputBalances map[int]map[runes.RuneId]uint128.Uint128, allocated map[int]map[runes.RuneId]uint128.Uint128) error {
|
||||
// getCurrentBalance returns the current balance of the pkScript and runeId since last flush
|
||||
getCurrentBalance := func(ctx context.Context, pkScript []byte, runeId runes.RuneId) (uint128.Uint128, error) {
|
||||
balance, err := p.runesDg.GetBalancesByPkScriptAndRuneId(ctx, pkScript, runeId, uint64(tx.BlockHeight-1))
|
||||
balance, err := p.runesDg.GetBalanceByPkScriptAndRuneId(ctx, pkScript, runeId, uint64(tx.BlockHeight-1))
|
||||
if err != nil {
|
||||
if errors.Is(err, errs.NotFound) {
|
||||
return uint128.Zero, nil
|
||||
}
|
||||
return uint128.Uint128{}, errors.Wrap(err, "failed to get balance by pk script and rune id")
|
||||
}
|
||||
return balance.Amount, nil
|
||||
|
||||
@@ -219,7 +219,7 @@ func (r *Repository) GetBalancesByRuneId(ctx context.Context, runeId runes.RuneI
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *Repository) GetBalancesByPkScriptAndRuneId(ctx context.Context, pkScript []byte, runeId runes.RuneId, blockHeight uint64) (*entity.Balance, error) {
|
||||
func (r *Repository) GetBalanceByPkScriptAndRuneId(ctx context.Context, pkScript []byte, runeId runes.RuneId, blockHeight uint64) (*entity.Balance, error) {
|
||||
balance, err := r.queries.GetBalanceByPkScriptAndRuneId(ctx, gen.GetBalanceByPkScriptAndRuneIdParams{
|
||||
Pkscript: hex.EncodeToString(pkScript),
|
||||
RuneID: runeId.String(),
|
||||
|
||||
Reference in New Issue
Block a user