peerAddrPortPairs = [] for optName in optNames: addrPort = configParser.get('peer-config', optName) ipaddr, port = addrPort.strip().rsplit(':', maxsplit=1) port = int(port) peerAddrPortPairs.append((ipaddr, port)) file = open(contentFilePath, 'r', encoding='utf-8') words = file.readline().split(' ') effectiveData = GetEffectiveData(words) file.close() while BC.height < len(effectiveData): height = bytes(str(BC.height), 'utf-8').ljust(8, b' ') content = effectiveData[BC.height] parentHash = GetMd5AsHex(BC.GetTop()) timestamp = bytes(time.asctime()[4:24], 'utf-8') Node = None while Node is None: Node = GetValidNode(content, height, localId, timestamp, parentHash) timestamp = time.asctime()[4:24] BC.Update(Node, True) # print chain for i in range(BC.height): print(str(BC.chain[i])[2:-1])
for optName in optNames: addrPort = configParser.get('peer-config', optName) ipaddr, port = addrPort.strip().rsplit(':', maxsplit=1) port = int(port) peerAddrPortPairs.append((ipaddr, port)) file = open(contentFilePath, 'r', encoding='utf-8') words = file.readline().split(' ') effectiveData = GetEffectiveData(words) file.close() localAddrPort = (localAddr, localPort) syncer = sync.Sync(BC, localAddrPort, peerAddrPortPairs, RTO) while BC.height < len(effectiveData): # work out the component in the block we are going to dig in this round height = bytes(str(BC.height), 'utf-8').ljust(8, b' ') content = effectiveData[BC.height] parentHash = GetMd5AsHex(BC.GetTop()) timestamp = bytes(time.asctime()[4:24], 'utf-8') Node = GetValidNode(content, height, localId, timestamp, parentHash, difficulty) if Node is not None: BC.Update(Node, False) syncer.DoSync() # print chain for i in range(BC.height): print(str(BC.chain[i])[2:-1])