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)
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)
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)
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)
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)
def send(self): Network.sendData(self.addrRecv, self.serialize(), False)
def sendFailure(self, message): Network.sendData(self.addrRecv, message, False)
def send(self): self.addrList.append(self.addrFrom) Network.sendData(self.addrRecv, self.serialize(), False)