def update_listings(self):
        try:
            if self.protocol.multiplexer is None:
                return reactor.callLater(1, self.update_listings)
            fname = os.path.join(DATA_FOLDER, "store", "listings.pickle")
            if os.path.exists(fname):
                with open(fname, 'r') as f:
                    data = pickle.load(f)
            else:
                data = {}

            l = objects.Listings()
            l.ParseFromString(self.db.listings.get_proto())
            for listing in l.listing:
                contract_hash = listing.contract_hash
                c = Contract(self.db, hash_value=contract_hash, testnet=self.protocol.multiplexer.testnet)
                if contract_hash not in data or time.time() - data[contract_hash] > 500000:
                    for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
                        self.kserver.set(digest(keyword.lower()), unhexlify(c.get_contract_id()),
                                         self.kserver.node.getProto().SerializeToString())
                    data[contract_hash] = time.time()
                if c.check_expired():
                    c.delete(True)
                    if contract_hash in data:
                        del data[contract_hash]
            guid = KeyChain(self.db).guid
            moderator = Profile(self.db).get().moderator
            if (guid not in data or time.time() - data[guid] > 500000) and moderator:
                self.make_moderator()
                data[guid] = time.time()
            with open(fname, 'w') as f:
                pickle.dump(data, f)
        except Exception:
            pass
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/market/network.py/Server.update_listings/original