# Path: hippiehug-package/hippiehug/Chain.py
# class DocChain(Chain):
#     """A chain that stores hashes of documents. Construct like a *Chain*."""
# 
#     def multi_add(self, items):
#         """Add multiple items to seal a new block."""
# 
#         docs = list(map(Document, items))
#         for d in docs:
#             self.store[d.hid] = d
# 
#         docs_id = list(map(lambda d: d.hid, docs))
#         Chain.multi_add(self, docs_id)
# 
#     def get(self, block_index, item_index, evidence=None):
#         """Get a sealed item, and optionally a bundle of evidence."""
# 
#         ## Get Doc and check its hash
#         item = Chain.get(self, block_index, item_index, evidence)
#         d = self.store[item]
#         check_hash(item, d)
# 
#         if evidence != None:
#             evidence[d.hid] = d
# 
#         return self.store[item].item
# 
#     def check(self, root, block_index, item_index, item):
#         """Check that an item is within the structure at a specific point."""
#         ret = True
#         ret = ret and (self.root() == root)
#         ret = ret and (self.get(block_index, item_index) == item)
#         return ret


import cProfile
import StringIO
import pstats
from hippiehug import DocChain
from os import urandom
from __future__ import print_function


N = 10000

def main(data):
	c = DocChain()

	for i in range(N):
		c.multi_add([data[i]])

if __name__ == "__main__":
	pr = cProfile.Profile()

	data = []
	for _ in range(N):
		data += [urandom(32)]


	pr.enable()
	main(data)
	pr.disable()


# Path: hippiehug-package/hippiehug/Chain.py
# class DocChain(Chain):
#     """A chain that stores hashes of documents. Construct like a *Chain*."""
# 
#     def multi_add(self, items):
#         """Add multiple items to seal a new block."""
# 
#         docs = list(map(Document, items))
#         for d in docs:
#             self.store[d.hid] = d
# 
#         docs_id = list(map(lambda d: d.hid, docs))
#         Chain.multi_add(self, docs_id)
# 
#     def get(self, block_index, item_index, evidence=None):
#         """Get a sealed item, and optionally a bundle of evidence."""
# 
#         ## Get Doc and check its hash
#         item = Chain.get(self, block_index, item_index, evidence)
#         d = self.store[item]
#         check_hash(item, d)
# 
#         if evidence != None:
#             evidence[d.hid] = d
# 
#         return self.store[item].item
# 
#     def check(self, root, block_index, item_index, item):
#         """Check that an item is within the structure at a specific point."""
#         ret = True
#         ret = ret and (self.root() == root)
#         ret = ret and (self.get(block_index, item_index) == item)
#         return ret


# Path: hippiehug-package/speedtest_chain.py
import cProfile
import StringIO
import pstats
from hippiehug import DocChain
from os import urandom

from __future__ import print_function


N = 10000

def main(data):
	c = DocChain()

	for i in range(N):
		c.multi_add([data[i]])

if __name__ == "__main__":
	pr = cProfile.Profile()

	data = []
	for _ in range(N):
		data += [urandom(32)]


	pr.enable()
	main(data)
	pr.disable()


	s = StringIO.StringIO()