code: def namedb_get_account_delta(cur, address, token_type, block_id, vtxindex):
      
      sql = 'SELECT * FROM accounts WHERE address = ? AND type = ? AND (block_id <= ? OR block_id == ? AND vtxindex <= ?) ORDER BY block_id DESC, vtxindex DESC LIMIT 2;'
      args = (address, token_type, block_id, block_id, vtxindex)
  
      rows = namedb_query_execute(cur, sql, args)
      data = []
      for r in rows:
          tmp = {}
          tmp.update(r)
          data.append(tmp)
  
      if len(data) != 2:
          return None
  
      # the current account state must land on this block_id/vtxindex
      if data[0]['block_id'] != block_id or data[0]['vtxindex'] != vtxindex:
          return None
  
      return {'current': data[0], 'prior': data[1]}
docs: Get the account state for a token type at the given (block_id,vtxindex), plus the account state for
      the same token type at the prior operation.
  
      The current account must have been debited or credited at (block_id,vtxindex)
  
      Returns {'current': ..., 'prior': ...} on success
      Returns None on error