def channel_name(self): channel_name = "".join(map(lambda x, y: x+y, self.sender, self.receiver)) peer_channel_name= "".join(map(lambda x, y: x+y, self.receiver, self.sender)) if ChannelState(peer_channel_name).find_channel(): return peer_channel_name else: return channel_name
def settle_raw_tx(address, channel_name, txdata, signature): sig_in_channel = ChannelState(channel_name) if sig_in_channel.senderinDB == address: sig_in_channel.update_sender_signature(signature) elif sig_in_channel.recieverinDB == address: sig_in_channel.update_receiver_signature(signature) Message.set_message_done(address, channel_name) else: return "address not match the channel" Message.set_message_done(address, channel_name) if sig_in_channel.sender_signature and sig_in_channel.receiver_signature: print("sig_in_channel") raw_data = blockchain.construct_deposit_raw_tx( txdata, sig_in_channel.sender_signature, sig_in_channel.receiver_signature, sig_in_channel.contract_hash) blockchain.send_raw_transaction(raw_data) return "Success" else: return None
def channel_name(self): channel_name = ChannelState.query_channel_name(self.sender, self.receiver) return channel_name if channel_name else generate_channel_name(self.sender, self.receiver)
def __init__(self, sender, receiver): self.sender = sender self.receiver = receiver ChannelState.__init__(self, self.channel_name)
def split_channel_name(channel_name): channel = ChannelState(channel_name) sender_addr = channel.senderinDB receiver_addr = channel.recieverinDB return sender_addr, receiver_addr