github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/sdk/python/sawtooth_sdk/processor/handler.py (about) 1 # Copyright 2017 Intel Corporation 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # ------------------------------------------------------------------------------ 15 16 import abc 17 18 19 class TransactionHandler(object, metaclass=abc.ABCMeta): 20 """ 21 TransactionHandler is the Abstract Base Class that defines the business 22 logic for a new transaction family. 23 24 The family_name, family_versions, and namespaces properties are 25 used by the processor to route processing requests to the handler. 26 """ 27 28 @abc.abstractproperty 29 def family_name(self): 30 """ 31 family_name should return the name of the transaction family that this 32 handler can process, e.g. "intkey" 33 """ 34 pass 35 36 @abc.abstractproperty 37 def family_versions(self): 38 """ 39 family_versions should return a list of versions this transaction 40 family handler can process, e.g. ["1.0"] 41 """ 42 pass 43 44 @abc.abstractproperty 45 def namespaces(self): 46 """ 47 namespaces should return a list containing all the handler's 48 namespaces, e.g. ["abcdef"] 49 """ 50 pass 51 52 @abc.abstractmethod 53 def apply(self, transaction, context): 54 """ 55 Apply is the single method where all the business logic for a 56 transaction family is defined. The method will be called by the 57 transaction processor upon receiving a TpProcessRequest that the 58 handler understands and will pass in the TpProcessRequest and an 59 initialized instance of the Context type. 60 """ 61 pass