Skip to content

INDY-1879: faster way for pool transactions ordering #1010

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

Merged
merged 5 commits into from
Dec 11, 2018

Conversation

Toktar
Copy link
Contributor

@Toktar Toktar commented Dec 4, 2018

  • remove getNodeData fron PoolManager
  • remove getAllTxn from nodeServicesChanged
  • remove getAllTxn from onPoolMembershipChange
  • getNodeName - change to using _ordered_node_ids

@Toktar Toktar changed the title Task 1879 slow pool txns INDY-1879: faster way for pool transactions ordering Dec 4, 2018
# `onPoolMembershipChange` method can be called only after txn added to ledger
if len(seqNos) == 0:
if self.ledger.getBySeqNo(get_seq_no(txn)) is None:
self._set_node_order(nodeNym, node_services=txn_data[DATA].get(SERVICES, None))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the condition is True, the this is a logic error, that's why we just raise and Exception.
Why do we call _set_node_order here?
Moreover, maybe we should remove the check if self.ledger.getBySeqNo(get_seq_no(txn)) at all, since onPoolMembershipChange can be called only after txn is already in the ledger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call _set_node_order to bring state _ordered_node_services in the same way as _ordered_node_ids. To add to both dicts data of a new transaction. But this is not important and can be removed.
We can remove this check but if error will happen it will not be checked. If it's ok, I will remove this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

# Assuming ALIAS does not change
_, nodeTxn = self.getNodeInfoFromLedger(nym)
return nodeTxn[DATA][ALIAS]
return self._ordered_node_ids[nym]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment # Assuming ALIAS does not change needs to be kept.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -391,10 +391,6 @@ def merkleRootHash(self) -> str:
def txnSeqNo(self) -> int:
return self.ledger.seqNo

def getNodeData(self, nym):
_, nodeTxn = self.getNodeInfoFromLedger(nym)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove getNodeInfoFromLedger as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -421,23 +417,28 @@ def id(self):

def _load_nodes_order_from_ledger(self):
self._ordered_node_ids = OrderedDict()
self._ordered_node_services = dict()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better to use {} instead of dict().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

self._set_node_order(txn_data[TARGET_NYM],
node_name=txn_data[DATA][ALIAS])

def _set_node_order(self, node_nym, node_name=None, node_services=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a separate method for setting node_services for a node. There is no sense to do two distinct operations in one method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

sdk_node_theta_added,
tdir, tconf):
"""
An running node's port is changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A running

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ashcherbakov ashcherbakov merged commit 7f2891a into hyperledger:master Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants