Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/logs and signature #57

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: adicionar método que insere folha criando árvore caso não exista
Guilherme Fumagali Marques committed Jul 25, 2024
commit 77506a52d63f2322dc88703270c9d1a722608b66
4 changes: 3 additions & 1 deletion backend/bu_service/app/adapter/tlmanager_adapter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import requests
import os

import dotenv
import requests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essa lib está sendo utilizada? Se não, é bom tirar


dotenv.load_dotenv()

TL_MANAGER_URL = os.getenv('TL_MANAGER_URL')


def get_trees():
return requests.get(f'{TL_MANAGER_URL}/').json()

5 changes: 3 additions & 2 deletions backend/bu_service/app/controllers/bu_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging

from fastapi import APIRouter, UploadFile, File

from app.services import bu_service
@@ -12,5 +13,5 @@ async def create(file: UploadFile = File(...)):
file_content = await file.read()

logging.info(f"Received file {file_name}")
bu_service.insert(file_content, file_name)
return {"status": "ok"}
bu_parsed = bu_service.insert(file_content, file_name)
return {"status": "ok", "bu": bu_parsed.dict(exclude={"bu"})}
22 changes: 22 additions & 0 deletions backend/bu_service/app/services/tlmanager_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import logging

from app.adapter.tlmanager_adapter import *

TREE_DEFAULT_COMMITMENT_SIZE = os.getenv('TREE_DEFAULT_COMMITMENT_SIZE')


def insert_creating_tree_if_not_exists(tree_name, data, commitment_size=TREE_DEFAULT_COMMITMENT_SIZE):
insert_leaf_response = insert_leaf(tree_name, data)
logging.info(insert_leaf_response.json())
if insert_leaf_response.status_code != 200 and insert_leaf_response.json().get('message') == "Tree does not exist":
logging.info(f"Creating tree with name {tree_name}")
create_tree(tree_name, commitment_size)

logging.info(f"Trying to insert leaf for tree {tree_name} again")
insert_leaf_response = insert_leaf(tree_name, data)
logging.info(insert_leaf_response.json())

if insert_leaf_response.status_code != 200:
raise Exception("Failed to insert leaf")

return insert_leaf_response