def test_get_sender(self): hash_val = b'0' * 32 sig = ( b'\xf6\x12[\x1b\x04\xe6\xdb\xcb\xe5\xd2\x88\xe41\x89J\xb5\x83\x18\x11\xa8' b'A\xed\xfcRK\x9c5i{\xbd\xab|r\xdb\xeeX\x1dp\x9a\xb6\x0e\\<\xa2X\x81\x17\xc5' b'$\xfa\x86i\xe3\xf5\xc0\xd1\xd9d}+\x8f\xceqE\x1c') expected_sender = b'\x82{D\xd5=\xf2\x85@Wq;%\xcd\xd6S\xebp\xfe6\xc4' assert get_sender(hash_val, sig) == expected_sender
def submit_block(self, sig): signature = bytes.fromhex(sig) if (signature == b'\x00' * 65 or get_sender( self.current_block.hash, signature) != self.authority): raise InvalidBlockSignatureException('failed to submit a block') merkle_hash = self.current_block.merklize_transaction_set() self.root_chain.transact({ 'from': '0x' + self.authority.hex() }).submitBlock(merkle_hash, self.current_block_number) self.db.save_block(self.current_block, self.current_block_number) self.current_block_number += 1 self.current_block = Block() return merkle_hash
def submit_block(self, sig): signature = bytes.fromhex(sig) if (signature == b'\x00' * 65 or get_sender( self.current_block.hash, signature) != self.authority): raise InvalidBlockSignatureException('failed to submit a block') merkle_hash = self.current_block.merklize_transaction_set() authority_address = w3.toChecksumAddress('0x' + self.authority.hex()) self.root_chain.functions.submitBlock( merkle_hash, self.current_block_number).transact({'from': authority_address}) self.db.save_block(self.current_block, self.current_block_number) self.current_block_number = self.db.increment_current_block_num() self.current_block = Block() return merkle_hash
def sender(self): return get_sender(self.hash, self.sig)