Beispiel #1
0
    def BroadcastTransaction(self, request, context):

        transaction = pickle.loads(request.message)

        self.transactionLobby.append(transaction)

        return helloworld_pb2.Blank(message="Transaction Received")
Beispiel #2
0
    def BroadcastBlock(self, request, context):

        block = pickle.loads(request.message)

        self.blockLobby.append(block)

        return helloworld_pb2.Blank(message="Block Received")
Beispiel #3
0
    def SendPeer(self, request, context):
        print("Adding peer" + request.message)
        if request.message not in self.peers:
            self.peers.append(request.message)
            for x in self.peers:
                print("known nodes:" + str(x))

        print("Peers: " + str(self.peers))
        return helloworld_pb2.Blank(message="Added peer (Y)")
Beispiel #4
0
    def pullBlockSize(self):

        channel = grpc.insecure_channel(self.registration.addrMe)

        stub = helloworld_pb2_grpc.GreeterStub(channel)

        response = stub.PullBlockSize(helloworld_pb2.Blank(message=""))

        size = response.size

        #print("size is : " + str(size))

        return size
Beispiel #5
0
    def pullTransactions(self):

        channel = grpc.insecure_channel(self.registration.addrMe)

        stub = helloworld_pb2_grpc.GreeterStub(channel)

        response = stub.PullTransactions(helloworld_pb2.Blank(message=""))

        transaction = pickle.loads(response.message)

        #print("pulled transactions " + str(transaction))

        return transaction
Beispiel #6
0
    def returnPeers(self, address):

        channel = grpc.insecure_channel(address)

        stub = helloworld_pb2_grpc.GreeterStub(channel)

        response = stub.PullPeers(helloworld_pb2.Blank(message=""))

        knownPeers = []
        for x in response.message:
            knownPeers.append(x)

        return knownPeers
Beispiel #7
0
    def pullBlocks(self):

        channel = grpc.insecure_channel(self.registration.addrMe)

        stub = helloworld_pb2_grpc.GreeterStub(channel)

        response = stub.PullBlocks(helloworld_pb2.Blank(message=""))

        blocks = pickle.loads(response.message)

        knownBlocks = []
        for x in blocks:
            knownBlocks.append(x)

        return knownBlocks