예제 #1
0
 def send_ack(self, receiver_address, msg):
     assert isinstance(msg, (Ack, BaseError))
     assert isaddress(receiver_address)
     host_port = self.discovery.get(receiver_address)
     self.transport.send(self.raiden, host_port, msg.encode())
     self.sent_acks[msg.echo] = (receiver_address, msg)
     log.debug("MSGHASH SENT", echo=pex(msg.echo))
예제 #2
0
    def send(self, receiver_address, msg):
        assert isaddress(receiver_address)
        assert not isinstance(msg, (Ack, BaseError)), msg
        log.info("SENDING {} > {} : {}".format(pex(self.raiden.address),
                                               pex(receiver_address), msg))
        host_port = self.discovery.get(receiver_address)
        data = msg.encode()
        msghash = sha3(data)
        self.tries[msghash] = self.max_tries
        log.debug("MSGHASH SENT", msghash=pex(msghash))

        assert len(data) < self.max_message_size

        def repeater():
            while self.tries.get(msghash, 0) > 0:
                if not self.repeat_messages and self.tries[
                        msghash] < self.max_tries:
                    raise Exception("DEACTIVATED MSG resents {} {}".format(
                        pex(receiver_address), msg))
                self.tries[msghash] -= 1
                self.transport.send(self.raiden, host_port, data)
                gevent.sleep(self.try_interval)

            # Each sent msg must be acked. When msg is acked its hash is removed from self.tries
            if msghash in self.tries:
                assert False, "Node does not reply, fixme suspend node"

        gevent.spawn(repeater)
예제 #3
0
 def send_ack(self, receiver_address, msg):
     assert isinstance(msg, (Ack, BaseError))
     assert isaddress(receiver_address)
     host_port = self.discovery.get(receiver_address)
     self.transport.send(self.raiden, host_port, msg.encode())
     self.sent_acks[msg.echo] = (receiver_address, msg)
     log.debug("MSGHASH SENT", echo=pex(msg.echo))
예제 #4
0
    def send(self, receiver_address, msg):
        assert isaddress(receiver_address)
        assert not isinstance(msg, (Ack, BaseError)), msg
        log.info("SENDING {} > {} : {}".format(pex(self.raiden.address),
                                               pex(receiver_address), msg))
        host_port = self.discovery.get(receiver_address)
        data = msg.encode()
        msghash = sha3(data)
        self.tries[msghash] = self.max_tries
        log.debug("MSGHASH SENT", msghash=pex(msghash))

        assert len(data) < self.max_message_size

        def repeater():
            while self.tries.get(msghash, 0) > 0:
                if not self.repeat_messages and self.tries[msghash] < self.max_tries:
                    raise Exception(
                        "DEACTIVATED MSG resents {} {}".format(pex(receiver_address), msg))
                self.tries[msghash] -= 1
                self.transport.send(self.raiden, host_port, data)
                gevent.sleep(self.try_interval)

            # Each sent msg must be acked. When msg is acked its hash is removed from self.tries
            if msghash in self.tries:
                assert False, "Node does not reply, fixme suspend node"

        gevent.spawn(repeater)
예제 #5
0
    def __init__(self, raiden, asset_address):
        assert isinstance(raiden, raiden_service.RaidenService)
        assert isaddress(asset_address)
        self.raiden = raiden
        self.asset_address = asset_address
        self.channels = dict()  # receiver : Channel

        # create channels for contracts
        channelmanager = raiden.chain.channelmanager_by_asset(asset_address)
        assert isinstance(channelmanager, ChannelManagerContract)
        for netting_contract in channelmanager.nettingcontracts_by_address(raiden.address):
            self.add_channel(netting_contract)

        # create network graph for contract
        self.channelgraph = ChannelGraph(channelmanager)

        # TransferManager for asset
        self.transfermanager = transfermanager.TransferManager(self)
예제 #6
0
    def __init__(self, raiden, asset_address):
        assert isinstance(raiden, raiden_service.RaidenService)
        assert isaddress(asset_address)
        self.raiden = raiden
        self.asset_address = asset_address
        self.channels = dict()  # receiver : Channel

        # create channels for contracts
        channelmanager = raiden.chain.channelmanager_by_asset(asset_address)
        assert isinstance(channelmanager, ChannelManagerContract)
        for netting_contract in channelmanager.nettingcontracts_by_address(
                raiden.address):
            self.add_channel(netting_contract)

        # create network graph for contract
        self.channelgraph = ChannelGraph(channelmanager)

        # TransferManager for asset
        self.transfermanager = transfermanager.TransferManager(self)
예제 #7
0
    def send(self, receiver_address, msg):
        assert isaddress(receiver_address)
        assert not isinstance(msg, (Ack, BaseError)), msg
        print "SENDING {} > {} : {}".format(pex(self.raiden.address), pex(receiver_address), msg)
        host_port = self.discovery.get(receiver_address)
        msghash = msg.hash
        self.tries[msghash] = self.max_tries
        data = rlp.encode(msg)
        assert len(data) < self.max_message_size

        def repeater():
            while self.tries.get(msghash, 0) > 0:
                if not self.repeat_messages and self.tries[msghash] < self.max_tries:
                    raise Exception(
                        "DEACTIVATED MSG resents {} {}".format(pex(receiver_address), msg))
                self.tries[msghash] -= 1
                self.transport.send(self.raiden, host_port, data)
                gevent.sleep(self.try_interval)
            if msghash in self.tries:
                assert False, "Node does not reply, fixme suspend node"

        gevent.spawn(repeater)
예제 #8
0
 def request_transfer(self, asset_address, amount, target):
     assert isaddress(asset_address) and isaddress(target)
     assert asset_address in self.assets
     tm = self.raiden.assetmanagers[asset_address].transfermanager
     assert isinstance(tm, TransferManager)
     tm.request_transfer(amount, target)
예제 #9
0
    def send(self, recipient, msg):
#        assert msg.sender
        assert isaddress(recipient)
        self.protocol.send(recipient, msg)
예제 #10
0
 def __init__(self, sender=''):
     assert not sender or isaddress(sender)
     super(Signed, self).__init__(sender=sender)
예제 #11
0
 def send(self, recipient, msg):
     # assert msg.sender
     assert isaddress(recipient)
     self.protocol.send(recipient, msg)
예제 #12
0
파일: contracts.py 프로젝트: ms83/raiden
 def add_asset(self, asset_address):
     assert isaddress(asset_address)
     assert asset_address not in self.channelmanagercontracts
     self.channelmanagercontracts[asset_address] = ChannelManagerContract(self, asset_address)
예제 #13
0
 def sign(self, sender):  # fixme dummy
     assert isaddress(sender)
     self.sender = sender
     return self
예제 #14
0
파일: contracts.py 프로젝트: ms83/raiden
 def __init__(self, chain, asset_address):
     self.chain = chain
     assert isaddress(asset_address)
     self.asset_address = asset_address
     self.nettingcontracts = dict()  # address_A + addressB : NettingChannelContract
예제 #15
0
 def request_transfer(self, asset_address, amount, target):
     assert isaddress(asset_address) and isaddress(target)
     assert asset_address in self.assets
     tm = self.raiden.assetmanagers[asset_address].transfermanager
     assert isinstance(tm, TransferManager)
     tm.request_transfer(amount, target)
예제 #16
0
 def __init__(self, chain, asset_address):
     self.chain = chain
     assert isaddress(asset_address)
     self.asset_address = asset_address
     self.nettingcontracts = dict(
     )  # address_A + addressB : NettingChannelContract
예제 #17
0
파일: transport.py 프로젝트: ryepdx/raiden
 def register(self, nodeid, host, port):
     assert isaddress(nodeid)  # fixme, this is H(pubkey)
     self.h[nodeid] = (host, port)
예제 #18
0
 def register(self, nodeid, host, port):
     assert isaddress(nodeid)  # fixme, this is H(pubkey)
     self.h[nodeid] = (host, port)
예제 #19
0
 def add_asset(self, asset_address):
     assert isaddress(asset_address)
     assert asset_address not in self.channelmanagercontracts
     self.channelmanagercontracts[asset_address] = ChannelManagerContract(
         self, asset_address)
예제 #20
0
 def send_ack(self, receiver_address, msg):
     assert isinstance(msg,  (Ack, BaseError))
     assert isaddress(receiver_address)
     host_port = self.discovery.get(receiver_address)
     self.transport.send(self.raiden, host_port, rlp.encode(msg))
     self.sent_acks[msg.echo] = (receiver_address, msg)