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

Commit

Permalink
Merge pull request #335 from lzpap/release/3.1.0
Browse files Browse the repository at this point in the history
Release 3.1.0b1
  • Loading branch information
lzpap authored Jun 4, 2020
2 parents e0cdacb + 84a4dca commit f596c1a
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 925 deletions.
5 changes: 0 additions & 5 deletions docs/core_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ iri/references/api-reference>`__.
.. automethod:: Iota.get_node_info
.. automethod:: AsyncIota.get_node_info

``get_tips``
------------
.. automethod:: Iota.get_tips
.. automethod:: AsyncIota.get_tips

``get_transactions_to_approve``
-------------------------------
.. automethod:: Iota.get_transactions_to_approve
Expand Down
10 changes: 5 additions & 5 deletions docs/extended_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ tasks such as sending and receiving transfers.
.. automethod:: Iota.get_inputs
.. automethod:: AsyncIota.get_inputs

``get_latest_inclusion``
------------------------
.. automethod:: Iota.get_latest_inclusion
.. automethod:: AsyncIota.get_latest_inclusion

``get_new_addresses``
---------------------
.. automethod:: Iota.get_new_addresses
Expand All @@ -72,6 +67,11 @@ tasks such as sending and receiving transfers.
.. automethod:: Iota.get_transfers
.. automethod:: AsyncIota.get_transfers

``is_confirmed``
-----------------
.. automethod:: Iota.is_confirmed
.. automethod:: AsyncIota.is_confirmed

``is_promotable``
-----------------
.. automethod:: Iota.is_promotable
Expand Down
79 changes: 6 additions & 73 deletions iota/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,11 @@ def find_transactions(
def get_balances(
self,
addresses: Iterable[Address],
threshold: int = 100,
tips: Optional[Iterable[TransactionHash]] = None,
) -> dict:
"""
Similar to :py:meth:`get_inclusion_states`. Returns the
confirmed balance which a list of addresses have at the latest
confirmed milestone.
Returns the confirmed balance which a list of addresses have at the
latest confirmed milestone.
In addition to the balances, it also returns the milestone as
well as the index with which the confirmed balance was
Expand All @@ -330,9 +328,6 @@ def get_balances(
:param Iterable[Address] addresses:
List of addresses to get the confirmed balance for.
:param int threshold:
Confirmation threshold between 0 and 100.
:param Optional[Iterable[TransactionHash]] tips:
Tips whose history of transactions to traverse to find the balance.
Expand Down Expand Up @@ -364,30 +359,23 @@ def get_balances(
return asyncio.get_event_loop().run_until_complete(
super().get_balances(
addresses,
threshold,
tips,
)
)

def get_inclusion_states(
self,
transactions: Iterable[TransactionHash],
tips: Iterable[TransactionHash]
) -> dict:
"""
Get the inclusion states of a set of transactions. This is for
determining if a transaction was accepted and confirmed by the
network or not. You can search for multiple tips (and thus,
milestones) to get past inclusion states of transactions.
network or not.
:param Iterable[TransactionHash] transactions:
List of transactions you want to get the inclusion state
for.
:param Iterable[TransactionHash] tips:
List of tips (including milestones) you want to search for
the inclusion state.
:return:
``dict`` with the following structure::
Expand All @@ -410,10 +398,12 @@ def get_inclusion_states(
return asyncio.get_event_loop().run_until_complete(
super().get_inclusion_states(
transactions,
tips,
)
)

# Add an alias for this call, more descriptive
is_confirmed = get_inclusion_states

def get_missing_transactions(self) -> dict:
"""
Returns all transaction hashes that a node is currently requesting
Expand Down Expand Up @@ -568,33 +558,6 @@ def get_node_info(self) -> dict:
super().get_node_info()
)

def get_tips(self) -> dict:
"""
Returns the list of tips (transactions which have no other
transactions referencing them).
:return:
``dict`` with the following structure::
{
'hashes': List[TransactionHash],
List of tip transaction hashes.
'duration': int,
Number of milliseconds it took to complete the request.
}
References:
- https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference#gettips
- https://docs.iota.org/docs/dev-essentials/0.1/references/glossary
"""

# Execute original coroutine inside an event loop to make this method
# synchronous
return asyncio.get_event_loop().run_until_complete(
super().get_tips()
)

def get_transactions_to_approve(
self,
depth: int,
Expand Down Expand Up @@ -1201,36 +1164,6 @@ def get_inputs(
)
)

def get_latest_inclusion(
self,
hashes: Iterable[TransactionHash]
) -> Dict[str, Dict[TransactionHash, bool]]:
"""
Fetches the inclusion state for the specified transaction
hashes, as of the latest milestone that the node has processed.
Effectively, this is :py:meth:`get_node_info` +
:py:meth:`get_inclusion_states`.
:param Iterable[TransactionHash] hashes:
List of transaction hashes.
:return:
``dict`` with the following structure::
{
"states": Dict[TransactionHash, bool]
``dict`` with one boolean per transaction hash in
``hashes``.
}
"""
# Execute original coroutine inside an event loop to make this method
# synchronous
return asyncio.get_event_loop().run_until_complete(
super().get_latest_inclusion(hashes)
)

def get_new_addresses(
self,
index: int = 0,
Expand Down
70 changes: 6 additions & 64 deletions iota/api_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,11 @@ async def find_transactions(
async def get_balances(
self,
addresses: Iterable[Address],
threshold: int = 100,
tips: Optional[Iterable[TransactionHash]] = None,
) -> dict:
"""
Similar to :py:meth:`get_inclusion_states`. Returns the
confirmed balance which a list of addresses have at the latest
confirmed milestone.
Returns the confirmed balance which a list of addresses have at the
latest confirmed milestone.
In addition to the balances, it also returns the milestone as
well as the index with which the confirmed balance was
Expand All @@ -332,9 +330,6 @@ async def get_balances(
:param Iterable[Address] addresses:
List of addresses to get the confirmed balance for.
:param int threshold:
Confirmation threshold between 0 and 100.
:param Optional[Iterable[TransactionHash]] tips:
Tips whose history of transactions to traverse to find the balance.
Expand Down Expand Up @@ -362,29 +357,22 @@ async def get_balances(
"""
return await core.GetBalancesCommand(self.adapter)(
addresses=addresses,
threshold=threshold,
tips=tips,
)

async def get_inclusion_states(
self,
transactions: Iterable[TransactionHash],
tips: Iterable[TransactionHash]
) -> dict:
"""
Get the inclusion states of a set of transactions. This is for
determining if a transaction was accepted and confirmed by the
network or not. You can search for multiple tips (and thus,
milestones) to get past inclusion states of transactions.
network or not.
:param Iterable[TransactionHash] transactions:
List of transactions you want to get the inclusion state
for.
:param Iterable[TransactionHash] tips:
List of tips (including milestones) you want to search for
the inclusion state.
:return:
``dict`` with the following structure::
Expand All @@ -403,9 +391,11 @@ async def get_inclusion_states(
"""
return await core.GetInclusionStatesCommand(self.adapter)(
transactions=transactions,
tips=tips,
)

# Add an alias, more descriptive
is_confirmed = get_inclusion_states

async def get_missing_transactions(self) -> dict:
"""
Returns all transaction hashes that a node is currently requesting
Expand Down Expand Up @@ -540,28 +530,6 @@ async def get_node_info(self) -> dict:
"""
return await core.GetNodeInfoCommand(self.adapter)()

async def get_tips(self) -> dict:
"""
Returns the list of tips (transactions which have no other
transactions referencing them).
:return:
``dict`` with the following structure::
{
'hashes': List[TransactionHash],
List of tip transaction hashes.
'duration': int,
Number of milliseconds it took to complete the request.
}
References:
- https://docs.iota.org/docs/node-software/0.1/iri/references/api-reference#gettips
- https://docs.iota.org/docs/dev-essentials/0.1/references/glossary
"""
return await core.GetTipsCommand(self.adapter)()

async def get_transactions_to_approve(
self,
depth: int,
Expand Down Expand Up @@ -1123,32 +1091,6 @@ async def get_inputs(
securityLevel=security_level
)

async def get_latest_inclusion(
self,
hashes: Iterable[TransactionHash]
) -> Dict[str, Dict[TransactionHash, bool]]:
"""
Fetches the inclusion state for the specified transaction
hashes, as of the latest milestone that the node has processed.
Effectively, this is :py:meth:`get_node_info` +
:py:meth:`get_inclusion_states`.
:param Iterable[TransactionHash] hashes:
List of transaction hashes.
:return:
``dict`` with the following structure::
{
"states": Dict[TransactionHash, bool]
``dict`` with one boolean per transaction hash in
``hashes``.
}
"""
return await extended.GetLatestInclusionCommand(self.adapter)(hashes=hashes)

async def get_new_addresses(
self,
index: int = 0,
Expand Down
1 change: 0 additions & 1 deletion iota/commands/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from .get_neighbors import *
from .get_node_api_configuration import *
from .get_node_info import *
from .get_tips import *
from .get_transactions_to_approve import *
from .get_trytes import *
from .interrupt_attaching_to_tangle import *
Expand Down
8 changes: 1 addition & 7 deletions iota/commands/core/get_balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,11 @@ def __init__(self) -> None:
f.Unicode(encoding='ascii', normalize=False),
),

'threshold':
f.Type(int) |
f.Min(0) |
f.Max(100) |
f.Optional(default=100),

'tips': StringifiedTrytesArray(TransactionHash),
},

allow_missing_keys={
'threshold', 'tips',
'tips',
},
)

Expand Down
9 changes: 0 additions & 9 deletions iota/commands/core/get_inclusion_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,5 @@ def __init__(self) -> None:
# Required parameters.
'transactions':
StringifiedTrytesArray(TransactionHash) | f.Required,

# Optional parameters.
'tips':
StringifiedTrytesArray(TransactionHash) |
f.Optional(default=[]),
},

allow_missing_keys={
'tips',
},
)
4 changes: 3 additions & 1 deletion iota/commands/core/get_node_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import filters as f

from iota import TransactionHash
from iota import TransactionHash, Address
from iota.commands import FilterCommand, RequestFilter, ResponseFilter
from iota.filters import Trytes

Expand Down Expand Up @@ -34,6 +34,8 @@ def __init__(self) -> None:
class GetNodeInfoResponseFilter(ResponseFilter):
def __init__(self) -> None:
super(GetNodeInfoResponseFilter, self).__init__({
'coordinatorAddress':
f.ByteString(encoding='ascii') | Trytes(Address),
'latestMilestone':
f.ByteString(encoding='ascii') | Trytes(TransactionHash),

Expand Down
Loading

0 comments on commit f596c1a

Please sign in to comment.