Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pow/nonce - python #1113

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 2 additions & 43 deletions bindings/python/iota_sdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from iota_sdk.client._utils import ClientUtils
from iota_sdk.secret_manager.secret_manager import LedgerNanoSecretManager, MnemonicSecretManager, StrongholdSecretManager, SeedSecretManager
from iota_sdk.types.block import Block
from iota_sdk.types.common import HexStr, Node, AddressAndAmount
from iota_sdk.types.common import HexStr, Node
from iota_sdk.types.feature import Feature
from iota_sdk.types.native_token import NativeToken
from iota_sdk.types.network_info import NetworkInfo
Expand Down Expand Up @@ -41,20 +41,14 @@ def __init__(
self,
nodes: Optional[str | List[str]] = None,
primary_node: Optional[str] = None,
primary_pow_node: Optional[str] = None,
permanode: Optional[str] = None,
ignore_node_health: Optional[bool] = None,
api_timeout: Optional[timedelta] = None,
node_sync_interval: Optional[timedelta] = None,
remote_pow_timeout: Optional[timedelta] = None,
tips_interval: Optional[int] = None,
quorum: Optional[bool] = None,
min_quorum_size: Optional[int] = None,
quorum_threshold: Optional[int] = None,
user_agent: Optional[str] = None,
local_pow: Optional[bool] = None,
fallback_to_local_pow: Optional[bool] = None,
pow_worker_count: Optional[int] = None,
client_handle=None
):
"""Initialize the IOTA Client.
Expand All @@ -64,8 +58,6 @@ def __init__(
A single Node URL or an array of URLs.
primary_node :
Node which will be tried first for all requests.
primary_pow_node :
Node which will be tried first when using remote PoW, even before the primary_node.
permanode :
Permanode URL.
ignore_node_health :
Expand All @@ -74,10 +66,6 @@ def __init__(
Timeout for API requests.
node_sync_interval :
Interval in which nodes will be checked for their sync status and the [NetworkInfo](crate::NetworkInfo) gets updated.
remote_pow_timeout :
Timeout when sending a block that requires remote proof of work.
tips_interval :
Tips request interval during PoW in seconds.
quorum :
If node quorum is enabled. Will compare the responses from multiple nodes and only returns the response if 'quorum_threshold'% of the nodes return the same one.
min_quorum_size :
Expand All @@ -86,12 +74,6 @@ def __init__(
% of nodes that have to return the same response so it gets accepted.
user_agent :
The User-Agent header for requests.
local_pow :
Local proof of work.
fallback_to_local_pow :
Fallback to local proof of work if the node doesn't support remote PoW.
pow_worker_count :
The amount of threads to be used for proof of work.
client_handle :
An instance of a node client.
"""
Expand Down Expand Up @@ -126,9 +108,6 @@ def get_remaining_nano_seconds(duration: timedelta):
if 'node_sync_interval' in client_config:
client_config['node_sync_interval'] = {'secs': int(client_config['node_sync_interval'].total_seconds(
)), 'nanos': get_remaining_nano_seconds(client_config['node_sync_interval'])}
if 'remote_pow_timeout' in client_config:
client_config['remote_pow_timeout'] = {'secs': int(client_config['remote_pow_timeout'].total_seconds(
)), 'nanos': get_remaining_nano_seconds(client_config['remote_pow_timeout'])}

client_config = humps.camelize(client_config)
client_config_str = dumps(client_config)
Expand Down Expand Up @@ -364,7 +343,7 @@ def get_node(self) -> Dict[str, Any]:
return self._call_method('getNode')

def get_network_info(self) -> NetworkInfo:
"""Gets the network related information such as network_id and min_pow_score.
"""Gets the network related information such as network_id.
"""
return from_dict(NetworkInfo, self._call_method('getNetworkInfo'))

Expand All @@ -378,26 +357,6 @@ def get_bech32_hrp(self) -> str:
"""
return self._call_method('getBech32Hrp')

def get_min_pow_score(self) -> int:
"""Returns the min pow score.
"""
return int(self._call_method('getMinPowScore'))

def get_tips_interval(self) -> int:
"""Returns the tips interval.
"""
return int(self._call_method('getTipsInterval'))

def get_local_pow(self) -> bool:
"""Returns if local pow should be used or not.
"""
return self._call_method('getLocalPow')

def get_fallback_to_local_pow(self) -> bool:
"""Get fallback to local proof of work timeout.
"""
return self._call_method('getFallbackToLocalPow')

def unhealthy_nodes(self) -> List[Dict[str, Any]]:
"""Returns the unhealthy nodes.
"""
Expand Down
2 changes: 0 additions & 2 deletions bindings/python/iota_sdk/types/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ class Block:
Attributes:
protocolVersion: The protocol version with which this block was issued.
parents: The parents of this block.
nonce: The nonce of this block.
payload: The optional payload of this block.
"""

protocolVersion: int
parents: List[HexStr]
nonce: str
payload: Optional[TaggedDataPayload |
TransactionPayload | MilestonePayload] = None

Expand Down
18 changes: 0 additions & 18 deletions bindings/python/iota_sdk/types/client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class ClientOptions:
Attributes:
primary_node (str):
Node which will be tried first for all requests.
primary_pow_node (str):
Node which will be tried first when using remote PoW, even before the primary_node.
nodes (List[str]):
Array of Node URLs.
permanode (str):
Expand All @@ -72,21 +70,10 @@ class ClientOptions:
Options for the MQTT broker.
protocolParameters (NodeInfoProtocol):
Protocol parameters.
localPow (bool):
Local proof of work.
fallbackToLocalPow (bool):
Fallback to local proof of work if the node doesn't support remote PoW.
tipsInterval (int):
Tips request interval during PoW in seconds.
apiTimeout (Duration):
Timeout for API requests.
remotePowTimeout (Duration):
Timeout when sending a block that requires remote proof of work.
powWorkerCount (int):
The amount of threads to be used for proof of work.
"""
primaryNode: Optional[str] = None
primaryPowNode: Optional[str] = None
nodes: Optional[List[str]] = None
permanodes: Optional[List[str]] = None
ignoreNodeHealth: Optional[bool] = None
Expand All @@ -97,12 +84,7 @@ class ClientOptions:
userAgent: Optional[str] = None
brokerOptions: Optional[MqttBrokerOptions] = None
protocolParameters: Optional[NodeInfoProtocol] = None
localPow: Optional[bool] = None
fallbackToLocalPow: Optional[bool] = None
tipsInterval: Optional[int] = None
apiTimeout: Optional[Duration] = None
remotePowTimeout: Optional[Duration] = None
powWorkerCount: Optional[int] = None

def as_dict(self):
config = {k: v for k, v in self.__dict__.items() if v is not None}
Expand Down
4 changes: 1 addition & 3 deletions bindings/python/iota_sdk/types/network_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

@dataclass
class NetworkInfo:
"""Network and PoW related information.
"""Network related information.
"""

protocolParameters: NodeInfoProtocol
localPow: bool
tipsInterval: int
2 changes: 0 additions & 2 deletions bindings/python/iota_sdk/types/node_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ class NodeInfoProtocol:
bech32Hrp: The HRP prefix used for Bech32 addresses in the network.
tokenSupply: TokenSupply defines the current token supply on the network.
version: The version of the protocol running.
minPowScore: The minimum pow score of the network.
rentStructure: The rent structure used by given node/network.
"""
networkName: str
bech32Hrp: str
tokenSupply: str
version: int
minPowScore: float
rentStructure: RentStructure


Expand Down
Loading