Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# coding: utf-8
import Savoir
import random
import string
from timeit import default_timer as timer
# All values must be in hex before stored in Multichain
def hexlify(s):
return s.encode().hex()
def unhexlify(s):
return bytes.fromhex(s).decode()
rpcuser='multichainrpc'
rpcpassword='CcSnnhc7bgeJdrWtVDxFKRYc56DG4ZXpuHFCEout71FD'
rpchost = 'localhost'
rpcport = '7200'
chainname = 'testchain'
api = Savoir.Savoir(rpcuser, rpcpassword, rpchost, rpcport, chainname)
streams = ['stream1','stream2','stream3','stream4','stream5','stream6','stream7']
for s in streams:
api.create('stream', s, True)
api.subscribe(s)
size = 1000
print('Loading...')
start = timer()
for _ in range(size):
key = ''.join([random.choice(string.ascii_letters) for _ in range(5)])
val = hexlify(''.join([random.choice(string.ascii_letters) for _ in range(5)]))
for s in streams:
api.publish(s, key, val)
elapsed = timer()-start
print('Elapsed: ' + str(elapsed))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment