Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit b63d239

Browse files
committed
Fixed errors when invoking getTransfers.
- Non-tail transactions (e.g., change transactions) no longer cause `getTransfers` to asplode.
1 parent 404e923 commit b63d239

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/iota/commands/extended/get_transfers.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,40 +71,49 @@ def _execute(self, request):
7171

7272
if hashes:
7373
# Sort transactions into tail and non-tail.
74-
tails = set()
75-
non_tails = set()
74+
tail_transaction_hashes = set()
75+
non_tail_bundle_hashes = set()
7676

7777
gt_response = GetTrytesCommand(self.adapter)(hashes=hashes)
78-
transactions = list(map(
78+
all_transactions = list(map(
7979
Transaction.from_tryte_string,
8080
gt_response['trytes'],
81-
))
81+
)) # type: List[Transaction]
8282

83-
for txn in transactions:
83+
for txn in all_transactions:
8484
if txn.is_tail:
85-
tails.add(txn.hash)
85+
tail_transaction_hashes.add(txn.hash)
8686
else:
8787
# Capture the bundle ID instead of the transaction hash so that
8888
# we can query the node to find the tail transaction for that
8989
# bundle.
90-
non_tails.add(txn.bundle_hash)
90+
non_tail_bundle_hashes.add(txn.bundle_hash)
9191

92-
if non_tails:
93-
for txn in self._find_transactions(bundles=list(non_tails)):
92+
if non_tail_bundle_hashes:
93+
for txn in self._find_transactions(bundles=list(non_tail_bundle_hashes)):
9494
if txn.is_tail:
95-
tails.add(txn.hash)
95+
if txn.hash not in tail_transaction_hashes:
96+
all_transactions.append(txn)
97+
tail_transaction_hashes.add(txn.hash)
98+
99+
# Filter out all non-tail transactions.
100+
tail_transactions = [
101+
txn
102+
for txn in all_transactions
103+
if txn.hash in tail_transaction_hashes
104+
]
96105

97106
# Attach inclusion states, if requested.
98107
if inclusion_states:
99108
gli_response = GetLatestInclusionCommand(self.adapter)(
100-
hashes = list(tails),
109+
hashes = list(tail_transaction_hashes),
101110
)
102111

103-
for txn in transactions:
112+
for txn in tail_transactions:
104113
txn.is_confirmed = gli_response['states'].get(txn.hash)
105114

106115
# Find the bundles for each transaction.
107-
for txn in transactions:
116+
for txn in tail_transactions:
108117
gb_response = GetBundlesCommand(self.adapter)(transaction=txn.hash)
109118
txn_bundles = gb_response['bundles'] # type: List[Bundle]
110119

0 commit comments

Comments
 (0)