Exemplo n.º 1
0
def demo_hashtable():
    RB = HashTableRB()
    D = RB.E
    print D
    for i in range(10):
        D = RB.insert(i, D)
        print D
Exemplo n.º 2
0
def demo_hashtable():
    RB = HashTableRB()
    D = RB.E
    print D
    for i in range(10):
        D = RB.insert(i, D)
        print D
Exemplo n.º 3
0
def demo_hashsoup(table={}):
    # Create N trees
    N = 100
    inds = range(N)
    import random
    random.shuffle(inds)
    RB = HashTableRB(table=table)
    D = RB.E
    index = [D]
    for i in inds:
        D = RB.insert(i, D)
        index.append(D)

    index2 = [RB.E]
    for D,i in zip(index,inds):
        D = RB.insert(i, D)
        index2.append(D)

    assert index == index2

    D = RB.reconstruct(index[1])
    print D, index[1]
Exemplo n.º 4
0
def demo_hashsoup(table={}):
    # Create N trees
    N = 100
    inds = range(N)
    import random
    random.shuffle(inds)
    RB = HashTableRB(table=table)
    D = RB.E
    index = [D]
    for i in inds:
        D = RB.insert(i, D)
        index.append(D)

    index2 = [RB.E]
    for D, i in zip(index, inds):
        D = RB.insert(i, D)
        index2.append(D)

    assert index == index2

    D = RB.reconstruct(index[1])
    print D, index[1]
Exemplo n.º 5
0
def demo_replay():
    RB = HashTableRB(MerkleNodeDigest)
    MerkleTree = RB.E
    txs = transactions_in_order()
    with open('./testdb/vofile_132267.json', 'r') as vofile:
        for i, (nHeight, tx_id, txn) in enumerate(txs):
            #RB = HashTableRB(MerkleNodeDigest, table=LevelDict(hashtable), validate=True)
            #RB = MerkleRedBlack(MerkleNodeDigest)
            vo = pickle.load(vofile)
            import random
            if random.random() < 0.00:
                vo = perturb(vo)  # Random fuzz-test errors
            RB = ReplayTraversal(vo, MerkleNodeDigest)
            MerkleTree = reduce(partial(apply_update, RB),
                                updates_in_transaction(nHeight, tx_id, txn),
                                MerkleTree)
            print nHeight, i, len(vo), hexlify(MerkleTree)
            if nHeight > 1532: break