Example #1
0
	def __init__( self, database, poolname ):
		self.db = database
		self.poolname = poolname
		self.config = self.db.getPool( self.poolname )
		self.address = self.config['address']
		self.port = self.config['port']
		self.username = self.config['username']
		self.password = self.config['password']
		self.timeout = int( self.config['timeout'] )
		
		self.authorizationStr = base64.b64encode(self.username + ":" + self.password).replace('\n','')	
		self.id = 0
		
		self.target = ""
		
		self.logger = logging.getLogger( "PoolManager.Pool.GetWork" )
		
		try:
			self.target = self.config['target']
		except:
			self.target = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000"
			
		self.targetInt = sha2int( sha2x( self.target ) )
		
		self.header = { "X-Mining-Extensions": "longpoll", "Authorization": "Basic " + self.authorizationStr, "User-Agent": "polcbm", "Content-Type": "text/plain" }
		self.url = "http://" + self.address + ":" + str(self.port)
		
		#Pool of http objects which will hopefully fix the memory issue.
		self.httpPool = ResourcePool( self.makeHttp )
Example #2
0
    def getUser(self, username, password):
        if password == "":
            return None

        return self.collection.find_one({
            "username":
            username,
            "password":
            base64.b64encode(sha2x(password))
        })
Example #3
0
    def addUser(self, username, password):
        user = {}
        user["username"] = username
        user["password"] = base64.b64encode(sha2x(password))
        user["miners"] = []
        user["hashrate"] = 0
        user["shares"] = 0
        user["payoutAddress"] = ""
        user["level"] = 1

        return self.collection.save(user)
Example #4
0
    def addUser(self, username, password):
        user = {}
        user['username'] = username
        user['password'] = base64.b64encode(sha2x(password))
        user['miners'] = []
        user['hashrate'] = 0
        user['shares'] = 0
        user['payoutAddress'] = ""
        user['level'] = 1

        return self.collection.save(user)
Example #5
0
	def checkWorkValidity( self, minerName, work ):
		share = self.getShare( minerName, work )
		
		if share['data'][:4] != b'\1\0\0\0':
			{ "share": share, "status": False }
			
		hash = sha2x( share['data'] )
		
		if hash[28:] != b'\0\0\0\0':
			return { "share": share, "status": False }
			
		hashInt = sha2int( hash )
		
		if hashInt >= self.targetInt:
			return { "share": share, "status": False }
			
		return { "share": share, "status": True }
Example #6
0
    def checkWorkValidity(self, minerName, work):
        share = self.getShare(minerName, work)

        if share['data'][:4] != b'\1\0\0\0':
            {"share": share, "status": False}

        hash = sha2x(share['data'])

        if hash[28:] != b'\0\0\0\0':
            return {"share": share, "status": False}

        hashInt = sha2int(hash)

        if hashInt >= self.targetInt:
            return {"share": share, "status": False}

        return {"share": share, "status": True}
Example #7
0
    def __init__(self, database, poolname):
        self.db = database
        self.poolname = poolname
        self.config = self.db.getPool(self.poolname)
        self.address = self.config['address']
        self.port = self.config['port']
        self.username = self.config['username']
        self.password = self.config['password']
        self.timeout = int(self.config['timeout'])

        self.authorizationStr = base64.b64encode(self.username + ":" +
                                                 self.password).replace(
                                                     '\n', '')
        self.id = 0

        self.target = ""

        self.logger = logging.getLogger("PoolManager.Pool.GetWork")

        try:
            self.target = self.config['target']
        except:
            self.target = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000"

        self.targetInt = sha2int(sha2x(self.target))

        self.header = {
            "X-Mining-Extensions": "longpoll",
            "Authorization": "Basic " + self.authorizationStr,
            "User-Agent": "polcbm",
            "Content-Type": "text/plain"
        }
        self.url = "http://" + self.address + ":" + str(self.port)

        #Pool of http objects which will hopefully fix the memory issue.
        self.httpPool = ResourcePool(self.makeHttp)
Example #8
0
    def getUser(self, username, password):
        if password == "":
            return None

        return self.collection.find_one({"username": username, "password": base64.b64encode(sha2x(password))})