Scope future changes

This commit is contained in:
Patrick O'Grady 2020-10-27 11:28:45 -07:00
parent 9fa814a74a
commit e244336178
No known key found for this signature in database
GPG key ID: 8DE11C985C0C8D85

View file

@ -746,6 +746,7 @@ func (i *Indexer) GetScriptPubKeys(
// GetBlockLazy returns a *types.BlockResponse from the indexer's block storage. // GetBlockLazy returns a *types.BlockResponse from the indexer's block storage.
// All transactions in a block must be fetched individually. // All transactions in a block must be fetched individually.
// TODO: replace with GetBlock
func (i *Indexer) GetBlockLazy( func (i *Indexer) GetBlockLazy(
ctx context.Context, ctx context.Context,
blockIdentifier *types.PartialBlockIdentifier, blockIdentifier *types.PartialBlockIdentifier,
@ -755,6 +756,7 @@ func (i *Indexer) GetBlockLazy(
// GetBlockTransaction returns a *types.Transaction if it is in the provided // GetBlockTransaction returns a *types.Transaction if it is in the provided
// *types.BlockIdentifier. // *types.BlockIdentifier.
// TODO: remove method
func (i *Indexer) GetBlockTransaction( func (i *Indexer) GetBlockTransaction(
ctx context.Context, ctx context.Context,
blockIdentifier *types.BlockIdentifier, blockIdentifier *types.BlockIdentifier,
@ -783,13 +785,20 @@ func (i *Indexer) GetBalance(
currency *types.Currency, currency *types.Currency,
blockIdentifier *types.PartialBlockIdentifier, blockIdentifier *types.PartialBlockIdentifier,
) (*types.Amount, *types.BlockIdentifier, error) { ) (*types.Amount, *types.BlockIdentifier, error) {
// TODO: add block lazy transactional
blockResponse, err := i.GetBlockLazy(ctx, blockIdentifier) blockResponse, err := i.GetBlockLazy(ctx, blockIdentifier)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
amount, err := i.balanceStorage.GetBalance( // TODO: when false if we query unknown, this could cause issue
// TODO: add switch to not create unknown
dbTx := i.database.NewDatabaseTransaction(ctx, false)
defer dbTx.Discard(ctx)
amount, err := i.balanceStorage.GetBalanceTransactional(
ctx, ctx,
dbTx,
accountIdentifier, accountIdentifier,
currency, currency,
blockResponse.Block.BlockIdentifier, blockResponse.Block.BlockIdentifier,