예제 #1
0
    def run(self):
        #Start database
        self.db = database(username=self.dbuser,
                           password=self.dbpassword,
                           authsource=self.authsource,
                           authmechanism=self.authmechanism,
                           port=self.port,
                           host=self.host)
        self.db.connect()

        #Connect to node
        self.ocean = getelementsd(self.conf)
        print("connected to node - block count: " +
              str(self.ocean.getblockcount()))

        self.count = 0
        start = time.perf_counter()
        self.download_keys()
        end = time.perf_counter()
        print('downloaded ' + str(self.count) + ' key/address pairs in ' +
              str(end - start) + ' seconds.')

        print('watching database for changes...')
        with self.db.whitelist.watch() as stream:
            for change in stream:
                print('change to db detected:')
                if (change['operationType'] == 'update'):
                    self.update_change(change)
                if (change['operationType'] == 'insert'):
                    self.add_change(change)
                print('watching database for changes...')
예제 #2
0
# Copyright (c) 2018 The CommerceBlock Developers
# Distributed under the MIT software license, see the accompanying                                                                                             # file LICENSE or http://www.opensource.org/licenses/mit-license.php.

#Fetches the addresses and keys from the whitelist database and prints them in columns <address> <key>
from cb_idcheck.database import database

db = database()
db.connect()
for document in db.whitelist.find():
    keys = document['keys']
    addresses = document['addresses']
    for key, address in zip(keys, addresses):
        print(address, key)
예제 #3
0
        print(
            "Fetch the customer record that contains the customer1.addresses")
        pprint.pprint(
            self.whitelist.find_one({'addresses': customer1.addresses}))

        print(
            "Fetch the customer record that contains the first key belonging to customer 2"
        )
        pprint.pprint(self.whitelist.find_one({'keys': customer2.keys[0]}))

        print("Remove customer1 from the db:")
        self.whitelist.remove({"_id": customer1._id})

        print("Fetch customer1")
        pprint.pprint(self.getFromID(customer1._id))

        print("Remove customer2 from the db:")
        self.whitelist.remove({"_id": customer2._id})

        print("Fetch customer2")
        pprint.pprint(self.getFromID(customer2._id))

        print("Finished test.")


if __name__ == "__main__":
    from cb_idcheck import database
    db = database.database()
    db.parse_args()
    db.test()
예제 #4
0
 def __init__(self):
     self.db=database()
     self.id_api=cb_onfido()