def regist_channel(sender_addr, receiver_addr, asset_type,deposit, open_blockchain): """ This func is to register channel :param sender_addr: String, the sender address :param receiver_addr: String, receiver's address :param asset_type: String, asset type should be symbol name , asset id should be configured in the configure.json :param deposit: String, depoist number in block chain :param open_blockchain: Open block chain number :return: Dictionary, {"channel_name":channel_name, "trad_info":raw_tans} """ channel = Channel(sender_addr,receiver_addr) if channel.find_channel(): return {"error": "channel already exist"} else: raw_tans,state = blockchain.NewTransection(asset_type, sender_addr, Contract_addr, int(deposit)) if state: channel_name = channel.create(sender_deposit=int(deposit),reciever_deposit=0, open_block_number=int(open_blockchain),settle_timeout=10) return {"channel_name": channel_name, "trad_info": raw_tans} else: return {"channel_name":None, "trad_info":raw_tans}
def regist_channel(sender_addr, receiver_addr, asset_type, deposit, open_blockchain): """ This func is to register channel :param sender_addr: String, the sender address :param receiver_addr: String, receiver's address :param asset_type: String, asset type should be symbol name , asset id should be configured in the configure.json :param deposit: String, depoist number in block chain :param open_blockchain: Open block chain number :return: Dictionary, {"channel_name":channel_name, "trad_info":raw_tans} """ channel = Channel(sender_addr, receiver_addr) logger.info('start to register channel') if channel.qeury_channel(): return {"error": "channel already exist"} else: channel_name = channel.create(sender_deposit=int(deposit), open_block_number=int(open_blockchain), settle_timeout=10) if not channel_name: return { "channel_name": None, "contract_address": None, "trad_info": "on pub key or not register pub key" } channel.qeury_channel() raw_tans, tx_id, state = blockchain.deposit_transaction( asset_type, sender_addr, channel.contract_address, int(deposit)) if state: channel.update_channel_to_database(tx_id=tx_id, state=State.OPENING) return { "channel_name": channel_name, "contract_address": channel.contract_address, "trad_info": raw_tans } else: channel.delete_channel() channel.delete_channel_in_database() return { "channel_name": None, "contract_address": None, "trad_info": raw_tans }
def regist_channel(sender_addr, receiver_addr, asset_type, deposit, open_blockchain): """ :param sender_addr: :param receiver_addr: :param asset_type: :param deposit: :param open_blockchain: :return: """ channel = Channel(sender_addr, receiver_addr) if channel.find_channel(): return {"error": "channel already exist"} else: channel_name = channel.create(sender_deposit=int(deposit), reciever_deposit=0, open_block_number=int(open_blockchain), settle_timeout=10) raw_tans = blockchain.NewTransection(asset_type, sender_addr, Contract_addr, int(deposit)) return {"channel_name": channel_name, "trad_info": raw_tans}