Пример #1
0
 def __init__(self, my_port=50082, core_host=None, core_port=None):
     self.client_state = STATE_INIT
     print('Initializing ClientCore...')
     self.my_ip = self.__get_myip()
     print('Server IP address is set to ... ', self.my_ip)
     self.my_port = my_port
     self.my_core_host = core_host
     self.my_core_port = core_port
     self.cm = ConnectionManager4Edge(self.my_ip, self.my_port, core_host,
                                      core_port, self.__handle_message)
     self.mpm = MyProtocolMessageHandler()
     self.my_protocol_message_store = []
 def __init__(self, my_port=50082, core_node_host=None, core_node_port=None):
     self.server_state = STATE_INIT
     print('Initializeing server...')
     self.my_ip = self.__get_myip()
     self.my_port = my_port
     print('Server IP address is set to ...', self.my_ip)
     print('Server Port is set to ...', self.my_port)
     self.cm = ConnectionManager(self.my_ip, self.my_port, self.__handle_message)
     self.core_node_host = core_node_host
     self.core_node_port = core_node_port
     self.mpmh = MyProtocolMessageHandler()
     self.my_protocol_message_store = []
     self.bb = BlockBuilder()
     my_genesis_block = self.bb.generate_genesis_block()
     self.bm = BlockchainManager(my_genesis_block.to_dict())
     self.prev_block_hash = self.bm.get_hash(my_genesis_block.to_dict())
     self.tp = TransactionPool()
Пример #3
0
 def __init__(self, my_port=50082, core_node_host="172.17.0.2", core_node_port=50082):
     self.server_state = STATE_INIT
     print('Initializing server...')
     self.my_ip = self.__get_myip()
     print('Server IP address is set to ... ', self.my_ip)
     self.my_port = my_port
     self.cm = ConnectionManager(self.my_ip, self.my_port, self.__handle_message)
     self.mpmh = MyProtocolMessageHandler()
     self.core_node_host = core_node_host
     self.core_node_port = core_node_port
     self.bb = BlockBuilder()
     self.flag_stop_block_build = False
     self.is_bb_running = False
     my_genesis_block = self.bb.generate_genesis_block()
     self.bm = BlockchainManager(my_genesis_block.to_dict())
     self.prev_block_hash = self.bm.get_hash(my_genesis_block.to_dict())
     self.tp = TransactionPool()
Пример #4
0
    def __init__(self, my_port=50082, core_host=None, core_port=None, server_id=1, callback=None, mpmh_callback=None):
        self.client_state = STATE_INIT
        print('Initializing ClientCore...')
        self.my_ip = self.__get_myip()
        print('Server IP address is set to ... ', self.my_ip)
        self.my_port = my_port
        self.my_core_host = core_host
        self.my_core_port = core_port
        self.my_server_id = server_id
        self.cm = ConnectionManager4Edge(self.my_ip, self.my_port, core_host, core_port, self.__handle_message)
        self.mpmh = MyProtocolMessageHandler()
        self.mpm_store = MessageStore()
        self.mpmh_callback = mpmh_callback

        self.bb = BlockBuilder()
        my_genesis_block = self.bb.generate_genesis_block(self.my_server_id)
        self.bm = BlockchainManager(my_genesis_block.to_dict())
        self.callback = callback
Пример #5
0
 def __init__(self, my_port = 50082, core_node_host=None, core_node_port=None, pass_phrase=None):
   self.server_state = STATE_INIT
   print('Initializing server...')
   self.my_ip = self.__get_myip()
   print('Server IP address is set to ...', self.my_ip)
   self.my_port = my_port
   self.cm = ConnectinManager(self.my_ip, self.my_port, self.__handle_message)
   self.mpmh = MyProtocolMessageHandler()
   self.core_node_host = core_node_host
   self.core_node_port = core_node_port
   self.bb = BlockBuilder()
   my_genesis_block = self.bb.generate_genesis_block()
   self.bm = BlockchainManager(my_genesis_block.to_dict())
   self.prev_block_hash = self.bm.get_hash(my_genesis_block.to_dict())
   self.tp = TransactionPool()
   self.is_bb_running = False
   self.flag_stop_block_build = False
   self.mpm_store = MessageStore()
   self.km = KeyManager(None, pass_phrase)
   self.rsa_util = RSAUtil()
   self.um = UTXOManager(self.km.my_address())
Пример #6
0
    def __init__(self,
                 my_port=50082,
                 owner_node_host=None,
                 owner_node_port=None):
        self.server_state = STATE_INIT
        print('Initializing owner server...')
        self.my_ip = self.__get_myip()
        print('Server IP address is set to ... ', self.my_ip)
        self.my_port = my_port
        self.cm = ConnectionManager4Owner(self.my_ip, self.my_port,
                                          self.__handle_message, self)
        self.mpmh = MyProtocolMessageHandler()
        self.owner_node_host = owner_node_host
        self.owner_node_port = owner_node_port
        self.gs = DigitalSignature()

        self.AC = 0
        self.Accept_list = None  #Accept Count
        self.Ccount = 0
        self.Send_list = None
        self.REcount = 0
        self.RE_Send_list = None
Пример #7
0
    def __init__(self,
                 my_port=50082,
                 core_node_host=None,
                 core_node_port=None):
        self.server_state = STATE_INIT
        print('Initializing server...')
        self.my_ip = self.__get_myip()
        print('Server IP address is set to ... ', self.my_ip)
        self.my_port = my_port
        self.cm = ConnectionManager(self.my_ip, self.my_port,
                                    self.__handle_message, self)
        self.mpmh = MyProtocolMessageHandler()
        self.core_node_host = core_node_host
        self.core_node_port = core_node_port
        self.bb = BlockBuilder()
        self.flag_stop_block_build = True
        self.is_bb_running = False
        if main_level.get_genesis(LDB_P):
            self.bm = BlockchainManager()
            latest_dbd_block = main_level.get_latest_block(LDB_P)
            self.prev_block_hash = self.bm.get_hash(latest_dbd_block)
            block_num = level_param.get_block_num(PARAM_P) + len(self.bm.chain)
            new_block = self.bb.generate_new_block({}, self.prev_block_hash,
                                                   str(block_num), ADDRESS, {},
                                                   self)
            self.bm.set_reconnect_block(new_block.to_dict())
            self.prev_block_hash = self.bm.get_hash(new_block.to_dict())
        else:
            my_genesis_block = self.bb.generate_genesis_block()
            self.bm = BlockchainManager(my_genesis_block.to_dict())
            self.prev_block_hash = self.bm.get_hash(my_genesis_block.to_dict())
        self.tp = TransactionPool()

        if core_node_host and core_node_port:
            self.plz_share_db()
        else:
            self.flag_stop_block_build = False