Пример #1
0
 def send(self):
     payload = Network.sendData(self.addrRecv, self.serialize())
     message = MessageFactory.getInstance(MessageType.INV)
     message.addrRecv = self.addrRecv
     if message.deserialize(payload):
         message.onSuccess()
     else:
         message.onFailure(self.sendFailure)
Пример #2
0
 def send(self):
     payload = Network.sendData(self.addrRecv, self.serialize())
     message = MessageFactory.getInstance(MessageType.ADDR)
     if message.deserialize(payload):
         message.onSuccess()
     else:
         peer = Peer()
         peer.host = self.addrRecv
         Peers.removePeer(peer)
         message.onFailure(self.sendFailure)
Пример #3
0
    def send(self):
        peer = Peers.getPeerByHost(self.addrRecv)
        self.blockHashes.append(peer.chainHeadBlockHash)

        payload = Network.sendData(self.addrRecv, self.serialize())
        message = MessageFactory.getInstance(MessageType.INV)
        message.addrFrom = self.addrRecv
        if message.deserialize(payload):
            message.onSuccess()
        else:
            message.onFailure(self.sendFailure)
Пример #4
0
 def send(self):
     payload = Network.sendData(self.addrRecv, self.serialize())
     isValid = True
     message = MessageFactory.getInstance(MessageType.PONG)
     if message.deserialize(payload):
         if message.nonce == self.nonce:
             message.onSuccess()
         else:
             isValid = False 
     else:
         isValid = False 
     if isValid == False:
         peer = Peer()
         peer.host = self.addrRecv
         Peers.removePeer(peer)
         message.onFailure(self.sendFailure)
Пример #5
0
    def send(self):
        peer = Peers.getPeerByHost(self.addrRecv)
        if peer.lastVersionNonce == None:
            peer.lastVersionNonce = self.nonce
            Peers.addPeer(peer)
        else:
            self.nonce = peer.lastVersionNonce

        chainHeadBlock = Chain.getChain().getChainHeadBlock()
        self.chainHeadBlockHash = chainHeadBlock.hash()

        payload = Network.sendData(self.addrRecv, self.serialize())
        message = MessageFactory.getInstance(MessageType.VERACK)
        message.addrFrom = self.addrRecv
        if message.deserialize(payload):
            message.onSuccess()
        else:
            peer = Peer()
            peer.host = self.addrRecv
            Peers.removePeer(peer)
            message.onFailure(self.sendFailure)
Пример #6
0
 def send(self):
     Network.sendData(self.addrRecv, self.serialize(), False)
Пример #7
0
 def sendFailure(self, message):
     Network.sendData(self.addrRecv, message, False)
Пример #8
0
 def send(self):
     self.addrList.append(self.addrFrom)
     Network.sendData(self.addrRecv, self.serialize(), False)