oracle.py 579 B

1234567891011121314151617
  1. from connection.broadcast import BroadcastServer
  2. from connection.socket import SocketServer
  3. from .oracleParser import OracleParser
  4. import random
  5. import os
  6. class Oracle:
  7. def __init__(self, broadcast, broadcastPort):
  8. self.id = os.urandom(32)
  9. self.socketPort = int(random.random() * 50000 + 1024)
  10. self.parser = OracleParser(self) # ,socketPort=socketPort
  11. self.b = BroadcastServer(
  12. broadcastPort=broadcastPort, parser=self.parser, id=self.id
  13. )
  14. self.s = SocketServer(self.socketPort, parser=self.parser, id=self.id)