コード例 #1
0
def get_channel_state(address):
    """

    :param sender_addr:
    :param receiver_addr:
    :return:
    """
    channel_infos = []
    channels = get_channelnames_via_address(address)
    for channel in channels:
        ch = Channel(channel.sender, channel.receiver)
        channel_detail = [{
            "address": ch.sender,
            "deposit": ch.sender_deposit,
            "balance": ch.get_address_balance(ch.sender)
        }, {
            "address": ch.receiver,
            "deposit": ch.receiver_deposit,
            "balance": ch.get_address_balance(ch.receiver)
        }]
        channel_info = {
            "channel_name": ch.channel_name,
            "channel_state": str(State(ch.stateinDB)),
            "open_block": ch.open_block_number,
            "tx_info": channel_detail
        }
        channel_infos.append(channel_info)
    return channel_infos
コード例 #2
0
def get_channel_state(address):
    """
    :param sender_addr: String, the sender address
    :param receiver_addr: String, receiver's address
    :return: Dictionary, the chnnnel information
    """
    channel_infos =[]
    channels = get_channelnames_via_address(address)
    for channel in channels:
        channel_detail =[]
        ch = Channel(channel.sender, channel.receiver)
        sender_info = {"address": ch.sender,
                           "deposit": ch.sender_deposit,
                           "balance": ch.get_address_balance(ch.sender) if ch.get_address_balance(ch.sender) else 0}
        recevier_info = {"address": ch.receiver,
                           "deposit": ch.receiver_deposit,
                           "balance": ch.get_address_balance(ch.receiver) if ch.get_address_balance(ch.receiver) else 0}
        if ch.sender == address:
            channel_detail.append(sender_info)
            channel_detail.append(recevier_info)
        else:
            channel_detail.append(recevier_info)
            channel_detail.append(sender_info)
        channel_info  = {
            "channel_name": ch.channel_name,
            "channel_state": str(State(ch.stateinDB)),
            "open_block":ch.open_block_number,
             "tx_info": channel_detail
        }
        channel_infos.append(channel_info)
    return channel_infos
コード例 #3
0
ファイル: manager.py プロジェクト: trinity-project/trinity
def _get_channel_states_info(address):
    channel_infos = []
    channels = get_channelnames_via_address(address)
    for channel in channels:
        channel_detail = []
        ch = Channel(channel.sender, channel.receiver)
        sender_info = {
            "address":
            ch.sender,
            "deposit":
            ch.sender_deposit,
            "balance":
            ch.get_address_balance(ch.sender)
            if ch.get_address_balance(ch.sender) else 0
        }
        recevier_info = {
            "address":
            ch.receiver,
            "deposit":
            ch.receiver_deposit,
            "balance":
            ch.get_address_balance(ch.receiver)
            if ch.get_address_balance(ch.receiver) else 0
        }
        if ch.sender == address:
            channel_detail.append(sender_info)
            channel_detail.append(recevier_info)
        else:
            channel_detail.append(recevier_info)
            channel_detail.append(sender_info)
        channel_info = {
            "channel_name": ch.channel_name,
            "channel_state": str(State(ch.stateinDB)),
            "open_block": ch.open_block_number,
            "contract_address": ch.contract_address,
            "tx_info": channel_detail
        }
        channel_infos.append(channel_info)
    return channel_infos