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

[INDY-1327] change key-value in ReqIdrToTxn #712

Merged

Conversation

Toktar
Copy link
Contributor

@Toktar Toktar commented May 29, 2018

Changes:

  • now ReqIdrToTxn store data in map digest -> ledge_idseq_no
  • added field digest to txn

Toktar and others added 16 commits May 28, 2018 11:13
Changes
- now ReqIdrToTxn store data in map digest -> ledge_id<delimiter>seq_no

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: Andrew Nikitin <andrew.nikitin@dsr-corporation.com>
[INDY-1327] add protocol version getting
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Changes:
- fix test client_authn.py
- fix test test_req_to_txn.py

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@Toktar
Copy link
Contributor Author

Toktar commented May 31, 2018

test this please

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@Toktar
Copy link
Contributor Author

Toktar commented May 31, 2018

test this please

2 similar comments
@Toktar
Copy link
Contributor Author

Toktar commented May 31, 2018

test this please

@Toktar
Copy link
Contributor Author

Toktar commented May 31, 2018

test this please

@Toktar Toktar changed the title [WIP][INDY-1327] change key-value in ReqIdrToTxn [INDY-1327] change key-value in ReqIdrToTxn May 31, 2018
@Toktar
Copy link
Contributor Author

Toktar commented May 31, 2018

test this please

1 similar comment
@Toktar
Copy link
Contributor Author

Toktar commented May 31, 2018

test this please

@Toktar
Copy link
Contributor Author

Toktar commented Jun 1, 2018

Test this please

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@@ -11,30 +11,36 @@ class ReqIdrToTxn:
"""

def __init__(self, keyValueStorage: KeyValueStorage):
self.delimiter = "~"
Copy link
Contributor

Choose a reason for hiding this comment

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

It can be a static constant on class level

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

parse_data = val.split(self.delimiter)
return str(parse_data[0]), str(parse_data[1])

def _create_value(self, ledge_id, seq_no):
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: ledge_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


def _parse_value(self, val: string):
parse_data = val.split(self.delimiter)
return str(parse_data[0]), str(parse_data[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

So, we expected seqNo as int previously and not it's str. Does it break anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to return seqNo as int, but I don't sure that it's a good idea. In fact, we store in a seqNoDB string. And in the origin version of code we convert it to int after get() just in case.

@@ -11,30 +11,36 @@ class ReqIdrToTxn:
"""

def __init__(self, keyValueStorage: KeyValueStorage):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have unit tests for ReqIdrToTxn?

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 have only integration test in test_already_processed_requests(). Should to add unit tests too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please

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.

@@ -120,6 +120,10 @@ def get_req_id(txn):
return txn[TXN_PAYLOAD][TXN_PAYLOAD_METADATA].get(TXN_PAYLOAD_METADATA_REQ_ID, None)


def get_digest(txn):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add test for get_digest to test_txn_general_access_utils

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

@@ -196,7 +196,7 @@ def executePoolTxnBatch(self, ppTime, reqs, stateRoot, txnRoot) -> List:
:param reqs: request
"""
committedTxns = self.reqHandler.commit(len(reqs), stateRoot, txnRoot, ppTime)
self.node.updateSeqNoMap(committedTxns)
self.node.updateSeqNoMap(committedTxns, DOMAIN_LEDGER_ID)

Choose a reason for hiding this comment

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

Do you mean POOL_LEDGER_ID?

Copy link
Contributor Author

@Toktar Toktar Jun 4, 2018

Choose a reason for hiding this comment

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

Yes, thank you. I'm not sure, because this information is not correct to leave as a constant, but I didn't find another way.

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

req.get(f.SIGS.nm, None),
req.get(f.PROTOCOL_VERSION.nm, None)
).digest
sign = req.get("signature")

Choose a reason for hiding this comment

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

please replace "signature" with f.SIG.nm as you use before

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

Changes:
- add test test_get_digest()
- refactoring req_and_expected()
- refactoring ReqIdrToTxn

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
elif isinstance(req, str):
req_data = json.loads(req)
elif isinstance(req, Request):
req = Request(
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to use named arguments here

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

@@ -246,7 +259,8 @@ def do_req_to_txn(req_data, req_op):

append_payload_metadata(result,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test to test_txn_init_utils

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

Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
Signed-off-by: toktar <renata.toktar@dsr-corporation.com>
@Toktar
Copy link
Contributor Author

Toktar commented Jun 4, 2018

test this please

2 similar comments
@Toktar
Copy link
Contributor Author

Toktar commented Jun 4, 2018

test this please

@Toktar
Copy link
Contributor Author

Toktar commented Jun 4, 2018

test this please

@ashcherbakov ashcherbakov merged commit f4d1063 into hyperledger:master Jun 5, 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.

None yet

3 participants