def get(self, blockhash): serialized_block = None try: serialized_block = self.blockDB[repr(blockhash)] except KeyError: return None f = cStringIO.StringIO(serialized_block) ret = CBlock() ret.deserialize(f) ret.calc_sha256() return ret
def create_block(hashprev, coinbase, nTime=None): block = CBlock() if nTime is None: import time block.nTime = int(time.time() + 600) else: block.nTime = nTime block.hashPrevBlock = hashprev block.nBits = 0x207fffff # Will break after a difficulty adjustment... block.vtx.append(coinbase) block.hashMerkleRoot = block.calc_merkle_root() block.calc_sha256() return block
def create_block(hashprev, coinbase, nTime=None, nBits=None): block = CBlock() if nTime is None: import time block.nTime = int(time.time()+600) else: block.nTime = nTime block.hashPrevBlock = hashprev if nBits is None: block.nBits = 0x200f0f0f # Will break after a difficulty adjustment... else: block.nBits = nBits block.vtx.append(coinbase) block.hashMerkleRoot = block.calc_merkle_root() block.calc_sha256() return block
def create_block(hashprev, coinbase, nTime=None, nBits=None, hashFinalSaplingRoot=None): block = CBlock() if nTime is None: import time block.nTime = int(time.time() + 600) else: block.nTime = nTime block.hashPrevBlock = hashprev if hashFinalSaplingRoot is not None: block.hashFinalSaplingRoot = hashFinalSaplingRoot if nBits is None: block.nBits = 0x200f0f0f # Will break after a difficulty adjustment... else: block.nBits = nBits block.vtx.append(coinbase) block.hashMerkleRoot = block.calc_merkle_root() block.calc_sha256() return block