blockchain_trace.py 760 Bytes
Newer Older
1
from flask import request, Response
2
from messaging.ReconnectingMessageManager import ReconnectingMessageManager
3 4
import json

5 6
message_sender = ReconnectingMessageManager.getInstance()
message_sender.create_message_destination('inhub', 'direct')
7 8 9

def receive():
    body = request.json
10
    
11
    if isBlockchainTraceValid(body):
12
        message = {'type': 'blockchain-transaction', 'retries': 0, 'content': body}
13
        message_sender.send_message('inhub', 'trace-retrieval', json.dumps(message))
14 15
        return Response(status=201)
        
16
    return Response('ApplicationType is missing', status=400)
17 18

def isBlockchainTraceValid(trace) -> bool:
19
    # different for every use case, no global schema
Luca Braun's avatar
Luca Braun committed
20
    return 'ApplicationType' in trace and 'docType' in trace