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

Commit 424c894

Browse files
authored
Merge pull request #297 from lzpap/remove_tips_from_gis
Fixes #288 Remove tips from `get_inclusion_states`
2 parents 0d5197b + 24443f2 commit 424c894

12 files changed

+58
-525
lines changed

docs/extended_api.rst

-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ tasks such as sending and receiving transfers.
5252
.. automethod:: Iota.get_inputs
5353
.. automethod:: AsyncIota.get_inputs
5454

55-
``get_latest_inclusion``
56-
------------------------
57-
.. automethod:: Iota.get_latest_inclusion
58-
.. automethod:: AsyncIota.get_latest_inclusion
59-
6055
``get_new_addresses``
6156
---------------------
6257
.. automethod:: Iota.get_new_addresses

iota/api.py

+1-38
Original file line numberDiff line numberDiff line change
@@ -372,22 +372,16 @@ def get_balances(
372372
def get_inclusion_states(
373373
self,
374374
transactions: Iterable[TransactionHash],
375-
tips: Iterable[TransactionHash]
376375
) -> dict:
377376
"""
378377
Get the inclusion states of a set of transactions. This is for
379378
determining if a transaction was accepted and confirmed by the
380-
network or not. You can search for multiple tips (and thus,
381-
milestones) to get past inclusion states of transactions.
379+
network or not.
382380
383381
:param Iterable[TransactionHash] transactions:
384382
List of transactions you want to get the inclusion state
385383
for.
386384
387-
:param Iterable[TransactionHash] tips:
388-
List of tips (including milestones) you want to search for
389-
the inclusion state.
390-
391385
:return:
392386
``dict`` with the following structure::
393387
@@ -410,7 +404,6 @@ def get_inclusion_states(
410404
return asyncio.get_event_loop().run_until_complete(
411405
super().get_inclusion_states(
412406
transactions,
413-
tips,
414407
)
415408
)
416409

@@ -1201,36 +1194,6 @@ def get_inputs(
12011194
)
12021195
)
12031196

1204-
def get_latest_inclusion(
1205-
self,
1206-
hashes: Iterable[TransactionHash]
1207-
) -> Dict[str, Dict[TransactionHash, bool]]:
1208-
"""
1209-
Fetches the inclusion state for the specified transaction
1210-
hashes, as of the latest milestone that the node has processed.
1211-
1212-
Effectively, this is :py:meth:`get_node_info` +
1213-
:py:meth:`get_inclusion_states`.
1214-
1215-
:param Iterable[TransactionHash] hashes:
1216-
List of transaction hashes.
1217-
1218-
:return:
1219-
``dict`` with the following structure::
1220-
1221-
{
1222-
"states": Dict[TransactionHash, bool]
1223-
``dict`` with one boolean per transaction hash in
1224-
``hashes``.
1225-
}
1226-
1227-
"""
1228-
# Execute original coroutine inside an event loop to make this method
1229-
# synchronous
1230-
return asyncio.get_event_loop().run_until_complete(
1231-
super().get_latest_inclusion(hashes)
1232-
)
1233-
12341197
def get_new_addresses(
12351198
self,
12361199
index: int = 0,

iota/api_async.py

+1-34
Original file line numberDiff line numberDiff line change
@@ -369,22 +369,16 @@ async def get_balances(
369369
async def get_inclusion_states(
370370
self,
371371
transactions: Iterable[TransactionHash],
372-
tips: Iterable[TransactionHash]
373372
) -> dict:
374373
"""
375374
Get the inclusion states of a set of transactions. This is for
376375
determining if a transaction was accepted and confirmed by the
377-
network or not. You can search for multiple tips (and thus,
378-
milestones) to get past inclusion states of transactions.
376+
network or not.
379377
380378
:param Iterable[TransactionHash] transactions:
381379
List of transactions you want to get the inclusion state
382380
for.
383381
384-
:param Iterable[TransactionHash] tips:
385-
List of tips (including milestones) you want to search for
386-
the inclusion state.
387-
388382
:return:
389383
``dict`` with the following structure::
390384
@@ -403,7 +397,6 @@ async def get_inclusion_states(
403397
"""
404398
return await core.GetInclusionStatesCommand(self.adapter)(
405399
transactions=transactions,
406-
tips=tips,
407400
)
408401

409402
async def get_missing_transactions(self) -> dict:
@@ -1123,32 +1116,6 @@ async def get_inputs(
11231116
securityLevel=security_level
11241117
)
11251118

1126-
async def get_latest_inclusion(
1127-
self,
1128-
hashes: Iterable[TransactionHash]
1129-
) -> Dict[str, Dict[TransactionHash, bool]]:
1130-
"""
1131-
Fetches the inclusion state for the specified transaction
1132-
hashes, as of the latest milestone that the node has processed.
1133-
1134-
Effectively, this is :py:meth:`get_node_info` +
1135-
:py:meth:`get_inclusion_states`.
1136-
1137-
:param Iterable[TransactionHash] hashes:
1138-
List of transaction hashes.
1139-
1140-
:return:
1141-
``dict`` with the following structure::
1142-
1143-
{
1144-
"states": Dict[TransactionHash, bool]
1145-
``dict`` with one boolean per transaction hash in
1146-
``hashes``.
1147-
}
1148-
1149-
"""
1150-
return await extended.GetLatestInclusionCommand(self.adapter)(hashes=hashes)
1151-
11521119
async def get_new_addresses(
11531120
self,
11541121
index: int = 0,

iota/commands/core/get_inclusion_states.py

-9
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,5 @@ def __init__(self) -> None:
3131
# Required parameters.
3232
'transactions':
3333
StringifiedTrytesArray(TransactionHash) | f.Required,
34-
35-
# Optional parameters.
36-
'tips':
37-
StringifiedTrytesArray(TransactionHash) |
38-
f.Optional(default=[]),
39-
},
40-
41-
allow_missing_keys={
42-
'tips',
4334
},
4435
)

iota/commands/extended/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from .get_account_data import *
1515
from .get_bundles import *
1616
from .get_inputs import *
17-
from .get_latest_inclusion import *
1817
from .get_new_addresses import *
1918
from .get_transaction_objects import *
2019
from .get_transfers import *

iota/commands/extended/get_latest_inclusion.py

-52
This file was deleted.

iota/commands/extended/is_reattachable.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from iota import Address
66
from iota.commands import FilterCommand, RequestFilter, ResponseFilter
7-
from iota.commands.extended import FindTransactionObjectsCommand, \
8-
GetLatestInclusionCommand
9-
from iota.filters import StringifiedTrytesArray
7+
from iota.commands.extended import FindTransactionObjectsCommand
8+
from iota.commands.core import GetInclusionStatesCommand
9+
from iota.filters import Trytes, StringifiedTrytesArray
1010

1111
__all__ = [
1212
'IsReattachableCommand',
@@ -48,14 +48,15 @@ async def _execute(self, request: dict) -> dict:
4848
}
4949

5050
# Fetch inclusion states.
51-
inclusion_states = await GetLatestInclusionCommand(adapter=self.adapter)(
52-
hashes=list(transaction_map.values()),
51+
inclusion_states = GetInclusionStatesCommand(adapter=self.adapter)(
52+
transactions=list(transaction_map.values()),
5353
)
54-
inclusion_states = inclusion_states['states']
54+
inclusion_states_map = dict(zip(
55+
list(transaction_map.keys()), inclusion_states['states']))
5556

5657
return {
5758
'reattachable': [
58-
not inclusion_states[transaction_map[address]]
59+
not inclusion_states_map[address]
5960
for address in addresses
6061
],
6162
}

iota/commands/extended/utils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
WereAddressesSpentFromCommand
1111
from iota.commands.extended import FindTransactionObjectsCommand
1212
from iota.commands.extended.get_bundles import GetBundlesCommand
13-
from iota.commands.extended.get_latest_inclusion import \
14-
GetLatestInclusionCommand
13+
from iota.commands.core.get_inclusion_states import \
14+
GetInclusionStatesCommand
1515
from iota.crypto.addresses import AddressGenerator
1616
from iota.crypto.types import Seed
1717

@@ -123,12 +123,12 @@ async def get_bundles_from_transaction_hashes(
123123

124124
# Attach inclusion states, if requested.
125125
if inclusion_states:
126-
gli_response = await GetLatestInclusionCommand(adapter)(
127-
hashes=list(tail_transaction_hashes),
126+
gli_response = await GetInclusionStatesCommand(adapter)(
127+
transactions=list(tail_transaction_hashes),
128128
)
129129

130-
for txn in tail_transactions:
131-
txn.is_confirmed = gli_response['states'].get(txn.hash)
130+
for txn, state in zip(tail_transactions, gli_response['states']):
131+
txn.is_confirmed = state
132132

133133
# Find the bundles for each transaction.
134134
txn_bundles: List[Bundle] = (await GetBundlesCommand(adapter)(

0 commit comments

Comments
 (0)