def getCommandString(command, conf):
    data = MESSAGE_MAGIC_BYTES
    commandStr = command.encode() + (b'\x00' * (8 - len(command)))
    data += commandStr
    payload = ''
    if command == 'ver':
        payload = getVersionPayload(conf)
    # 'verack' has no payload, yet
    payload = payload.encode()
    payloadLen = len(payload)
    data += pack('>I', payloadLen)
    data += hashlib.sha512(payload).digest()[0:4] # hash the empty string if necessary
    return data + payload
dataset/ETHPy150Open Anenome/Bitlaw/src/bitlawui/threads/threadutils.py/getCommandString/original