forked from hyperledger/indy-plenum
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INDY-1173] add POOL_RESTART handling (hyperledger#582)
* INDY-1173: added ActionResult Signed-off-by: toktar <[email protected]> * INDY-1173: Refactoring POOL_RESTART Changes: -Add NodeController as a superclass for Restarter and Upgrader -Add action handler for new type of transaction that should not be saved at ledger -Change handlers logical Signed-off-by: toktar <[email protected]> * INDY-1173: Bagfix POOL_RESTART Changes: -fixed problem with auth -fixed problem with schedule validation Signed-off-by: toktar <[email protected]> * INDY-1173: refactoring Changes: - made LedgerRequestHandler abstract Signed-off-by: toktar <[email protected]> * INDY-1173: refactoring Changes: - change documentation - change handler logic of store operation types Signed-off-by: toktar <[email protected]> * INDY-1173: refactoring Changes: - remove OPERATION field - revert excess different Signed-off-by: toktar <[email protected]> * INDY-1173: refactoring Changes: - implementing abstract methods for action_req_handler.py - change sending reply logic Signed-off-by: toktar <[email protected]> * INDY-1173: Refactoring code style Signed-off-by: toktar <[email protected]> * INDY-1173: fixed code style in the node Signed-off-by: toktar <[email protected]> * INDY-1173: Added implementation of abstract methods changes: -Added implementation of abstract methods LedgerRequestHandler to ConfigReqHandler Signed-off-by: toktar <[email protected]> * INDY-1173: fixed code style Signed-off-by: toktar <[email protected]> * INDY-1173: fixed problems after merge Signed-off-by: toktar <[email protected]> * INDY-1173: refactoring node changes: - Removing an unnecessary handler call Signed-off-by: toktar <[email protected]> * INDY-1173:refactoring changes: -change operation_types in ledger_req_handler.py -change process_action logic Signed-off-by: toktar <[email protected]> * INDY-1173:refactoring changes: -rollback changes in operation_types Signed-off-by: toktar <[email protected]> * INDY-1173: refactoring changes: - Add ack Signed-off-by: toktar <[email protected]> * INDY-1184: bugfix Changes: - change reject format Signed-off-by: toktar <[email protected]>
- Loading branch information
Showing
13 changed files
with
177 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from plenum.common.request import Request | ||
from plenum.server.req_handler import RequestHandler | ||
|
||
|
||
class ActionReqHandler(RequestHandler): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def doStaticValidation(self, request: Request): | ||
pass | ||
|
||
def validate(self, req: Request): | ||
pass | ||
|
||
def apply(self, req: Request, cons_time: int): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
from plenum.server.req_handler import RequestHandler | ||
from plenum.common.request import Request | ||
from plenum.server.ledger_req_handler import LedgerRequestHandler | ||
|
||
|
||
class ConfigReqHandler(RequestHandler): | ||
class ConfigReqHandler(LedgerRequestHandler): | ||
def __init__(self, ledger, state): | ||
super().__init__(ledger, state) | ||
|
||
def doStaticValidation(self, request: Request): | ||
pass | ||
|
||
def get_query_response(self, request): | ||
pass | ||
|
||
def validate(self, req: Request): | ||
pass | ||
|
||
def apply(self, req: Request, cons_time: int): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from abc import ABCMeta, abstractmethod | ||
from typing import List | ||
|
||
import base58 | ||
|
||
from plenum.common.ledger import Ledger | ||
from plenum.common.request import Request | ||
from plenum.persistence.util import txnsWithSeqNo | ||
from plenum.server.req_handler import RequestHandler | ||
from stp_core.common.log import getlogger | ||
|
||
from state.state import State | ||
|
||
logger = getlogger() | ||
|
||
|
||
class LedgerRequestHandler(RequestHandler, metaclass=ABCMeta): | ||
""" | ||
Base class for request handlers | ||
Declares methods for validation, application of requests and | ||
state control | ||
""" | ||
|
||
query_types = set() | ||
write_types = set() | ||
|
||
def __init__(self, ledger: Ledger, state: State): | ||
self.state = state | ||
self.ledger = ledger | ||
|
||
def updateState(self, txns, isCommitted=False): | ||
""" | ||
Updates current state with a number of committed or | ||
not committed transactions | ||
""" | ||
|
||
def commit(self, txnCount, stateRoot, txnRoot, ppTime) -> List: | ||
""" | ||
:param txnCount: The number of requests to commit (The actual requests | ||
are picked up from the uncommitted list from the ledger) | ||
:param stateRoot: The state trie root after the txns are committed | ||
:param txnRoot: The txn merkle root after the txns are committed | ||
:return: list of committed transactions | ||
""" | ||
|
||
(seqNoStart, seqNoEnd), committedTxns = \ | ||
self.ledger.commitTxns(txnCount) | ||
stateRoot = base58.b58decode(stateRoot.encode()) | ||
# Probably the following assertion fail should trigger catchup | ||
assert self.ledger.root_hash == txnRoot, '{} {}'.format( | ||
self.ledger.root_hash, txnRoot) | ||
self.state.commit(rootHash=stateRoot) | ||
return txnsWithSeqNo(seqNoStart, seqNoEnd, committedTxns) | ||
|
||
def onBatchCreated(self, state_root): | ||
pass | ||
|
||
def onBatchRejected(self): | ||
pass | ||
|
||
@abstractmethod | ||
def doStaticValidation(self, request: Request): | ||
pass | ||
|
||
def is_query(self, txn_type): | ||
return txn_type in self.query_types | ||
|
||
def get_query_response(self, request): | ||
raise NotImplementedError | ||
|
||
@staticmethod | ||
def transform_txn_for_ledger(txn): | ||
return txn | ||
|
||
@property | ||
def operation_types(self) -> set: | ||
return self.write_types.union(self.query_types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.