def get_block_locator(self): block_locator = [] it = BlockIterator(self.database, self.database.get_mainchain()) stepsize = 1 while (it.hash != self.database.genesishash): block_locator.append(it.hash) i = 0 while it.hasprev() and i < stepsize: it.prev() i += 1 stepsize*= 2 #tmp speedup hack #if stepsize >= 128: # break block_locator.append(self.database.genesishash) return BlockLocator(1, block_locator)
def __init__(self, log, database, lasthash, firsthash=None): self.log = log self.database = database self.firsthash = firsthash self.lasthash = lasthash self.last = BlockIterator(database, lasthash)