<commit_before>import base64
import datetime

import binascii
import grpc

from cli import crypto
from endpoint_pb2_grpc import CommandServiceStub, QueryServiceStub
from primitive_pb2 import Signature
from block_pb2 import Transaction
from queries_pb2 import Query


def generateTransaction(account_id, commands, key_pair):
    payload = Transaction.Payload(
        commands=commands,
        creator_account_id=account_id,
        tx_counter=1,
        created_time=int(datetime.datetime.now().timestamp() * 1000)
    )
    payload_hash = crypto.sha3_256(payload.SerializeToString())
    sign = crypto.sign(key_pair, payload_hash)
    tx = Transaction(
        payload=payload,
        signature=[
            Signature(pubkey=key_pair.raw_public_key, signature=sign)
        ]
    )
    return tx


def generateQuery(account_id, qry, key_pair):
    payload = Query.Payload(
        **qry,
        creator_account_id=account_id,
        created_time=int(datetime.datetime.now().timestamp() * 1000),
        query_counter=1
    )
    payload_hash = crypto.sha3_256(payload.SerializeToString())
    sign = crypto.sign(key_pair, payload_hash)
    query = Query(
        payload=payload,
        signature=[
            Signature(pubkey=key_pair.raw_public_key, signature=sign)
        ]
    )
    return query


def sendTx(location, tx):
    try:
        channel = grpc.insecure_channel(location)
        stub = CommandServiceStub(channel)
        stub.Torii(tx, timeout=1)  # wait 1s
        return True
    except grpc.RpcError as e:
        print("== Grpc happens error ==\n"
              "- Server is active?: {} \n"
              "- What's happen?   : {} \n"
              .format(e.is_active(), e.details())
              )
        return False


def sendQuery(location, query):
    try:
        channel = grpc.insecure_channel(location)
        stub = QueryServiceStub(channel)
        stub.Find(query, timeout=1)  # wait 1s
        return True<commit_msg>Fix Signature list -> sig<commit_after>import base64
import datetime

import binascii
import grpc

from cli import crypto
from endpoint_pb2_grpc import CommandServiceStub, QueryServiceStub
from primitive_pb2 import Signature
from block_pb2 import Transaction
from queries_pb2 import Query


def generateTransaction(account_id, commands, key_pair):
    payload = Transaction.Payload(
        commands=commands,
        creator_account_id=account_id,
        tx_counter=1,
        created_time=int(datetime.datetime.now().timestamp() * 1000)
    )
    payload_hash = crypto.sha3_256(payload.SerializeToString())
    sign = crypto.sign(key_pair, payload_hash)
    tx = Transaction(
        payload=payload,
        signature=[
            Signature(pubkey=key_pair.raw_public_key, signature=sign)
        ]
    )
    return tx


def generateQuery(account_id, qry, key_pair):
    payload = Query.Payload(
        **qry,
        creator_account_id=account_id,
        created_time=int(datetime.datetime.now().timestamp() * 1000),
        query_counter=1
    )
    payload_hash = crypto.sha3_256(payload.SerializeToString())
    sign = crypto.sign(key_pair, payload_hash)
    query = Query(
        payload=payload,
        signature=Signature(pubkey=key_pair.raw_public_key, signature=sign)
    )
    return query


def sendTx(location, tx):
    try:
        channel = grpc.insecure_channel(location)
        stub = CommandServiceStub(channel)
        stub.Torii(tx, timeout=1)  # wait 1s
        return True
    except grpc.RpcError as e:
        print("== Grpc happens error ==\n"
              "- Server is active?: {} \n"
              "- What's happen?   : {} \n"
              .format(e.is_active(), e.details())
        )
        return False


def sendQuery(location, query):
    try:
        channel = grpc.insecure_channel(location)
        stub = QueryServiceStub(channel)
        stub.Find(query, timeout=1)  # wait 1s
        return True
{'fraction_non_alphanumeric': 0.09365404298874104, 'fraction_numerical': 0.014329580348004094, 'mean_word_length': 2.729961832061069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4762295', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1157, 'n_words': 251}