DurianStallSingapore / Zilliqa-Mining-Proxy

Mining Proxy between Zilliqa Nodes and Miners
https://proxy.getzil.com
GNU General Public License v3.0
28 stars 29 forks source link

Nicehash #30

Closed muhmad-f-k closed 3 years ago

muhmad-f-k commented 3 years ago

Hi. @ShengguangXiao Proxy stop keep order in the top when block 00 comes. And proxy to slow to get latest top price (always lose miners on block 00) since wont keep checking top price... Can figur out why.. Can you take a a look at NH py.

Unkownman086 commented 3 years ago

Hello, i am not able to run proxy at all, can i ask you what distro are you using?

muhmad-f-k commented 3 years ago

ubuntu 20.04

Unkownman086 commented 3 years ago

I am using ubuntu 20.04 too, but can't run it what python version are you using 3.7.2 ?

muhmad-f-k commented 3 years ago

yes. What you gonna do with it? dosnt work, you will never get hashrate when pow hit. If you good with python let me know.

Unkownman086 commented 3 years ago

no, i am python noob i have this error when running it: jacob@jacobsserver:/320gb/Zilliqa-Mining-Proxy$ python3.7 start.py Traceback (most recent call last): File "start.py", line 24, in from zilpool import poolserver File "/320gb/Zilliqa-Mining-Proxy/zilpool/poolserver.py", line 32, in from zilpool.stratum.stratum_server import * File "/320gb/Zilliqa-Mining-Proxy/zilpool/stratum/stratum_server.py", line 8, in from zilpool.database import pow, miner File "/320gb/Zilliqa-Mining-Proxy/zilpool/database/init.py", line 3, in from .basemodel import init_db, connect_to_db, get_cur_settings File "/320gb/Zilliqa-Mining-Proxy/zilpool/database/basemodel.py", line 27, in from mongoengine.connection import get_db, MongoEngineConnectionError ImportError: cannot import name 'MongoEngineConnectionError' from 'mongoengine.connection' (/usr/local/lib/python3.7/dist-packages/mongoengine-0.22.1-py3.7.egg/mongoengine/connection.py)

muhmad-f-k commented 3 years ago

IF you dont have any coding skills dont waste you time. yeah this mongoen thing pain in the ass,

Unkownman086 commented 3 years ago

Did you have the same problem?

muhmad-f-k commented 3 years ago

yeah, I dont remember how i got around this issue, have it on my node for months. its not issue its dependice issue. something not right on your os.

mitagmio commented 3 years ago

package mongoengine.connection version 0.22.1 don't have "MongoEngineConnectionError"

File connection.py

from pymongo import MongoClient, ReadPreference, uri_parser
from pymongo.database import _check_name

__all__ = [
    "DEFAULT_CONNECTION_NAME",
    "DEFAULT_DATABASE_NAME",
    "ConnectionFailure",
    "connect",
    "disconnect",
    "disconnect_all",
    "get_connection",
    "get_db",
    "register_connection",
]

DEFAULT_CONNECTION_NAME = "default"
DEFAULT_DATABASE_NAME = "test"
DEFAULT_HOST = "localhost"
DEFAULT_PORT = 27017

_connection_settings = {}
_connections = {}
_dbs = {}

READ_PREFERENCE = ReadPreference.PRIMARY

class ConnectionFailure(Exception):

FIX!!! Changein it "MongoEngineConnectionError" on "ConnectionFailure" in file Zilliqa-Mining-Proxy/zilpool/database/basemodel.py line 27: from mongoengine.connection import get_db, ConnectionFailure line 45: except ConnectionFailure:

File basemodel.py

import logging
from functools import wraps
from inspect import isclass
from cachetools import cached, TTLCache

from mongoengine import connect, Document, OperationError
from mongoengine.connection import get_db, ConnectionFailure

from zilpool.common.local import LocalProxy

db = LocalProxy(get_db)

def connect_to_db(config=None):
    """ connect_to_db at the begin of app initializing
    :param config: loaded config dict
    :return: None
    """
    uri = config.database["uri"]

    logging.critical(f"Connecting to {uri}")
    try:
        connect(host=uri)
        logging.critical("Database connected!")
    except ConnectionFailure:
        logging.fatal("Failed connect to MongoDB!")
        raise
muhmad-f-k commented 3 years ago

@mitagmio Hi. The problem proxy dont get real top price anyway from NH:D but thank you for the fix. (if not full_orders: return 2.98)

def get_top_price(self, top_n=1, excluded_orders=None, min_limit_speed=0.0, min_accepted_speed=0.0, max_price=None): pubAPI = public_api(self.host)

result = self.get_orders()

    full_orders = pubAPI.get_active_orders2(self.config["location"])
    logging.info(f"full orders: {full_orders}")
    if not full_orders:
        return 2.98
    if excluded_orders is None:
        excluded_orders = []
    full_orders = [order for order in full_orders if order["type"] == 'STANDARD' and order["id"] not in excluded_orders]
    orders = [order for order in full_orders if float(order["speedLimit"]) >= min_limit_speed
              and float(order["acceptedCurrentSpeed"]) >= min_accepted_speed]