def hash_header(header): header_bytes = header_to_string(header).decode('hex') if (header["version"] >= 7): hash_bytes = Hash(header_bytes) # new rules, sha256 else: hash_bytes = HashScrypt(header_bytes) # old scrypt header hashing return rev_hex(hash_bytes.encode('hex'))
def write_header(self, header, sync=True): if not self.headers_data: self.headers_offset = header.get('block_height') self.headers_data += header_to_string(header).decode('hex') if sync or len(self.headers_data) > 40*100: self.flush_headers() with self.cache_lock: chunk_index = header.get('block_height')/2016 if chunk_index in self.chunk_cache: del self.chunk_cache[chunk_index]
def write_header(self, header, sync=True): if not self.headers_data: self.headers_offset = header.get('block_height') self.headers_data += header_to_string(header).decode('hex') if sync or len(self.headers_data) > 40 * 100: self.flush_headers() with self.cache_lock: chunk_index = header.get('block_height') / 2016 if chunk_index in self.chunk_cache: del self.chunk_cache[chunk_index]
def write_header(self, header, sync=True): if not self.headers_data: self.headers_offset = header.get('block_height') self.headers_data += header_to_string(header).decode('hex') if sync or len(self.headers_data) > 40*100: self.flush_headers() with self.cache_lock: chunk_index = header.get('block_height')/BLOCKS_PER_CHUNK if self.chunk_cache.get(chunk_index): self.chunk_cache.pop(chunk_index)
def reader_header(block_height): global count headers_filename = os.path.join(headers_path, 'blockchain_headers') count = 0 h = b'' if os.path.exists(headers_filename): with open(headers_filename, 'rb') as f: f.seek(block_height * 80) h = f.read(80) with open('header_chunk_client', 'ab+') as the_file: the_file.write(h) if len(h) == 80: count = count + 1 h = header_from_string(h) return header_to_string(h)
def hash_header(header): return rev_hex(Hash(header_to_string(header).decode('hex')).encode('hex'))
def hash_header(header): return rev_hex( HashX11(header_to_string(header).decode('hex')).encode('hex'))
def hash_header(header): return rev_hex( coinhash.NeoscryptHash( header_to_string(header).decode('hex')).encode('hex'))