Skip to content

Instantly share code, notes, and snippets.

@zopyx
Last active October 8, 2017 16:23
Show Gist options
  • Save zopyx/b5ee732f5f92ce8c3b9485836bd7a50b to your computer and use it in GitHub Desktop.
Save zopyx/b5ee732f5f92ce8c3b9485836bd7a50b to your computer and use it in GitHub Desktop.
import os
import json
from bigchaindb_driver import BigchainDB
from bigchaindb_driver.crypto import generate_keypair
keyfile = 'keys.json'
bdb = BigchainDB( 'http://localhost:9984')
msg = '*'*100
if os.path.exists(keyfile):
with open(keyfile) as fp:
data = json.load(fp)
public_key = data['public_key']
private_key = data['private_key']
else:
key = generate_keypair()
with open(keyfile, 'w') as fp:
json.dump(dict(private_key=key.private_key, public_key=key.public_key), fp)
for i in range(1000):
print(i)
tx = bdb.transactions.prepare(
operation='CREATE',
signers=public_key,
asset={'data': {'message': msg + str(i)}})
signed_tx = bdb.transactions.fulfill(
tx,
private_keys=private_key)
bdb.transactions.send(signed_tx)
#real 0m17.866s
#user 0m7.307s
#sys 0m0.732s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment