def get_ratings(self, node_to_ask, listing_hash=None):
        """
        Query the given node for a listing of ratings/reviews for the given listing.
        """
        def get_result(result):
            try:
                verify_key = nacl.signing.VerifyKey(node_to_ask.pubkey)
                verify_key.verify(result[1][0], result[1][1])
                ratings = json.loads(result[1][0].decode("zlib"), object_pairs_hook=OrderedDict)
                ret = []
                for rating in ratings:
                    address = rating["tx_summary"]["address"]
                    buyer_key = rating["tx_summary"]["buyer_key"]
                    amount = rating["tx_summary"]["amount"]
                    listing_hash = rating["tx_summary"]["listing"]
                    proof_sig = rating["tx_summary"]["proof_of_tx"]
                    try:
                        verify_key.verify(str(address) + str(amount) + str(listing_hash) + str(buyer_key),
                                          base64.b64decode(proof_sig))

                        valid = bitcointools.ecdsa_raw_verify(json.dumps(rating["tx_summary"], indent=4),
                                                              bitcointools.decode_sig(rating["signature"]),
                                                              buyer_key)
                        if not valid:
                            raise Exception("Bitcoin signature not valid")

                        if "buyer_guid" in rating["tx_summary"] or "buyer_guid_key" in rating["tx_summary"]:
                            buyer_key_bin = unhexlify(rating["tx_summary"]["buyer_guid_key"])
                            buyer_key = nacl.signing.VerifyKey(buyer_key_bin)
                            buyer_key.verify(json.dumps(rating["tx_summary"], indent=4),
                                             base64.b64decode(rating["guid_signature"]))
                            h = nacl.hash.sha512(buyer_key_bin)
                            pow_hash = h[40:]
                            if int(pow_hash[:6], 16) >= 50 or rating["tx_summary"]["buyer_guid"] != h[:40]:
                                raise Exception('Invalid GUID')

                        ret.append(rating)
                    except Exception:
                        pass
                return ret
            except Exception:
                return None

        if node_to_ask.ip is None:
            return defer.succeed(None)
        a = "ALL" if listing_hash is None else listing_hash.encode("hex")
        self.log.info("fetching ratings for contract %s from %s" % (a, node_to_ask))
        d = self.protocol.callGetRatings(node_to_ask, listing_hash)
        return d.addCallback(get_result)
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/market/network.py/Server.get_ratings/original