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-1173] add POOL_RESTART handling #582

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bf29651
INDY-1173: added ActionResult
Toktar Mar 22, 2018
fc53001
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
Toktar Mar 23, 2018
682f54c
INDY-1173: Refactoring POOL_RESTART
Toktar Mar 27, 2018
0fdf438
INDY-1173: Bagfix POOL_RESTART
Toktar Mar 28, 2018
0ae333a
INDY-1173: refactoring
Toktar Mar 30, 2018
a3a7058
INDY-1173: refactoring
Toktar Apr 2, 2018
c432a8e
INDY-1173: refactoring
Toktar Apr 3, 2018
f8cfb54
INDY-1173: refactoring
Toktar Apr 3, 2018
fb9d395
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
Toktar Apr 5, 2018
cf14932
INDY-1173: Refactoring code style
Toktar Apr 5, 2018
de736d3
INDY-1173: fixing problem after merge
Toktar Apr 6, 2018
d1b5502
INDY-1173: fixed bug in a register_req_handler
Toktar Apr 6, 2018
3cc6b12
Merge branch 'story-1173-add-command-to-restart-pool' of https://gith…
Toktar Apr 6, 2018
1503fff
INDY-1173: fixed code style in the node
Toktar Apr 6, 2018
a754c11
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
Toktar Apr 10, 2018
25787cd
INDY-1173: Added implementation of abstract methods
Toktar Apr 10, 2018
5f07ea2
INDY-1173: fixed code style
Toktar Apr 10, 2018
c41c470
INDY-1173: fixed problems after merge
Toktar Apr 10, 2018
0a0cc96
INDY-1173: refactoring node
Toktar Apr 11, 2018
b89b699
INDY-1173:refactoring
Toktar Apr 12, 2018
8e501a2
INDY-1173:refactoring
Toktar Apr 12, 2018
007cc51
INDY-1173: refactoring
Toktar Apr 12, 2018
aa08fd5
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
Toktar Apr 13, 2018
5605a5d
INDY-1184: bugfix
Toktar Apr 17, 2018
427e1f5
Merge branch 'master' of https://github.com/hyperledger/indy-plenum i…
Toktar Apr 17, 2018
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
1 change: 1 addition & 0 deletions plenum/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
UPDATE_BLS_MULTI_SIG = "UPDATE_BLS_MULTI_SIG"

REPLY = "REPLY"
ACTION_RESULT = "ACTION_RESULT"

ORDERED = "ORDERED"
REQKEY = "REQKEY"
Expand Down
25 changes: 21 additions & 4 deletions plenum/common/messages/node_messages.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from typing import TypeVar, NamedTuple

from plenum.common.constants import NOMINATE, BATCH, REELECTION, PRIMARY, BLACKLIST, REQACK, REQNACK, REJECT, \
POOL_LEDGER_TXNS, ORDERED, PROPAGATE, PREPREPARE, PREPARE, COMMIT, CHECKPOINT, THREE_PC_STATE, CHECKPOINT_STATE, \
REPLY, INSTANCE_CHANGE, LEDGER_STATUS, CONSISTENCY_PROOF, CATCHUP_REQ, CATCHUP_REP, VIEW_CHANGE_DONE, CURRENT_STATE, \
MESSAGE_REQUEST, MESSAGE_RESPONSE, OBSERVED_DATA, BATCH_COMMITTED
from plenum.common.constants import NOMINATE, BATCH, REELECTION, PRIMARY, \
BLACKLIST, REQACK, REQNACK, REJECT, \
POOL_LEDGER_TXNS, ORDERED, PROPAGATE, PREPREPARE, PREPARE, COMMIT, \
CHECKPOINT, THREE_PC_STATE, CHECKPOINT_STATE, \
REPLY, INSTANCE_CHANGE, LEDGER_STATUS, CONSISTENCY_PROOF, CATCHUP_REQ, \
CATCHUP_REP, VIEW_CHANGE_DONE, CURRENT_STATE, \
MESSAGE_REQUEST, MESSAGE_RESPONSE, OBSERVED_DATA, BATCH_COMMITTED, \
ACTION_RESULT
from plenum.common.messages.client_request import ClientMessageValidator
from plenum.common.messages.fields import NonNegativeNumberField, IterableField, \
SerializedValueField, SignatureField, TieAmongField, AnyValueField, RequestIdentifierField, TimestampField, \
Expand Down Expand Up @@ -215,6 +219,19 @@ class Reply(MessageBase):
)


class ActionResult(MessageBase):
Copy link
Contributor

Choose a reason for hiding this comment

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

Such a subclass of MessageBase is not needed. Actually FieldValidator and its subclasses (MessageBase is one of them) are used for validation against schemas. Now ActionResult is not used in any schemas since Reply.result is defined as AnyValueField.

Moreover, Reply.result for an action should be just a dictionary with the specific fields, it should not be a simple class, because it must be transferred via network as a dictionary. For example, see Node.handle_get_txn_req - just a dictionary is used as Reply.result. (If you saw at MessageBase subclasses, please note that MessageBase is a subclass of Mapping, so MessageBase provides conversion to a dictionary. But in our case we should use just a dictionary because we need not validation facilities for the reply content.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If ActionResult should be a dictionary and shouldn't contains fields. Do we need this class? Can we remove it? At the time of the Reply creation, we will just put the dictionary with keys and values from the next comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should remove this class and put the dictionary as result to Reply.

typename = ACTION_RESULT
schema = (
(f.IDENTIFIER.nm, AnyValueField()),
(f.REQ_ID.nm, AnyValueField()),
(f.SIG.nm, AnyValueField()),
(f.OPERATION.nm, AnyValueField()),
(f.PROTOCOL_VERSION.nm, AnyValueField()),
(f.IS_SUCCESS.nm, AnyValueField()),
(f.MSG.nm, AnyValueField(optional=True, nullable=True))
Copy link
Contributor

Choose a reason for hiding this comment

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

The list of keys of Reply.result dictionary for an action must be as follows:

  • TXN_TYPE
  • f.IDENTIFIER
  • f.REQ_ID
  • f.IS_SUCCESS
  • f.MSG

)


class InstanceChange(MessageBase):
typename = INSTANCE_CHANGE
schema = (
Expand Down
2 changes: 2 additions & 0 deletions plenum/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class f: # provides a namespace for reusable field constants
ELECTION_DATA = Field('electionData', Any)
TXN_ID = Field('txnId', str)
REASON = Field('reason', Any)
IS_SUCCESS = Field('isSuccess', Any)
SENDER_CLIENT = Field('senderClient', str)
PP_TIME = Field("ppTime", float)
REQ_IDR = Field("reqIdr", List[Tuple[str, int]])
Expand Down Expand Up @@ -73,6 +74,7 @@ class f: # provides a namespace for reusable field constants
PRIMARY = Field("primary", dict)
SIGS = Field('signatures', dict)
PLUGIN_FIELDS = Field('plugin_fields', dict)
OPERATION = Field("operation", dict)


OPERATION = 'operation'
Expand Down