def checkrelay(chain_id): if chain_id in tennsb_blockchain_info: if 'relay_nsb' in tennsb_blockchain_info[chain_id]['user']: return tennsb_blockchain_info[chain_id]['user']['relay_nsb'] else: raise Missing('this chain has not relay-address' + chain_id) else: raise Missing('no such chainID: ' + chain_id)
def checkuser(chain_id, user_name): if is_tennsb_address(user_name): return user_name if chain_id in tennsb_blockchain_info: if user_name in tennsb_blockchain_info[chain_id]['user']: return tennsb_blockchain_info[chain_id]['user'][user_name] raise Missing('no user named ' + user_name + ' in ' + chain_id) else: raise Missing('no such chainID: ' + chain_id)
def insurance_claim(self, atte: Attestation, tid, state, nsb_addr=None, result=None, tcg=None, tx=None): if tx is None: tx = self.tx console_logger.info('isc({0}) claiming:\n Attestation: {1},\n tid:{2},\n state: {3}'.format( self.address, atte.__dict__, tid, state )) print(atte, "is not verified") if state == StateType.opened: if tcg is None: raise Missing("the opening time of Transaction must be given") return self.handle.funct('ChangeStateOpened', tx, tid, tcg) elif state == StateType.closed: if tcg is None: raise Missing("the close time of Transaction must be given") return self.handle.funct('ChangeStateClosed', tx, tid, tcg) elif state == StateType.open: if result is None: raise Missing("the result of Transaction must be given") return ( self.handle.funct('ChangeState', tx, tid, state), self.handle.funct('ChangeResult', tx, nsb_addr, tid, result) ) else: return self.handle.funct('ChangeState', tx, tid, state)
def update_funds(self, owner, tx): if owner not in self.owners: raise Missing('this address is not owner') console_logger.info('isc({}) updating funds'.format(self.address)) print(owner, "updated fund:", tx)
def gethost(chain_id): if chain_id in tennsb_blockchain_info: return tennsb_blockchain_info[chain_id]['host'] else: raise Missing('no such chainID: ' + chain_id)