Skip to content

Commit

Permalink
quick stash
Browse files Browse the repository at this point in the history
  • Loading branch information
csajedi committed Sep 1, 2021
1 parent e445a7f commit 6493175
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
11 changes: 7 additions & 4 deletions automa/core/queue.py
@@ -1,11 +1,14 @@
import dataset

class Queue:
"""Holds the incoming submissions until they can be processed. For now it is a simple datastore"""

def __init__():
pass
def __init__(self,db_string):
self.db=dataset.connect(db_string)

def accept(tape_record):
pass
def accept(self,tape_dict):
self.db["tapes"].insert(tape_dict)
self.db["debts"].update(dict(user=tape_dict.assigned,))

def get_debts():
pass
14 changes: 9 additions & 5 deletions automa/main.py
Expand Up @@ -3,12 +3,12 @@
from loguru import logger
from core import queue
from core.errors import *

from core.queue import *
# JSON-RPC entrypoint
api_v1 = jsonrpc.Entrypoint("/v1")

# Server singletons: database, queue and library handler

queue = Queue()
# RPC Methods


Expand All @@ -25,13 +25,18 @@ def allocation(client: str, capability: int, nonce: int, signature: str) -> dict

logger.info("allocation requested for {} ", client)

@api_v1.method(errors=[])
def submission(assigned: str, workload_ID:str,turing_machines:dict, nonce: int, signature: str) -> dict:
"""Get assigned a range of TMs to compute and submit before the epoch ends """

logger.info("submission made for {} ", workload_ID)

@api_v1.method()
def network() -> dict:
"""Gets the latest volunteer network information"""
pass

# entrypoint: ./api/v1/... methods=stamp, tree, validate
# entrypoint: ./api/v1/... methods=account, allocation, network
app = jsonrpc.API()
app.bind_entrypoint(api_v1)
app.add_middleware(
Expand All @@ -47,15 +52,14 @@ def network() -> dict:
async def startup():
logger.add("file_{time}.log")
logger.info("Service is Spinning Up")
logger.info("Provisioning auth store...")
logger.info("Starting tape store...")


# Dump the logs if a shutdown is occuring.
@app.on_event("shutdown")
async def shutdown():
# ideally you'd put this backup in a docker volume, S3 or Grafana-compatible store.
logger.info("Service is Shutting Down")
# make one last attempt to anchor the sidetree before shutdown


if __name__ == "__main__":
Expand Down

0 comments on commit 6493175

Please sign in to comment.