Exemple #1
0
 def test_same_as_partial_match(self):
     namedpool = Pool('S9', 'CoolPool', 'tcp://stratum.pool.com',
                      'workername.', 0)
     available_pool = AvailablePool('S9', None, namedpool.url,
                                    'workername.MinerName', 'x', 0)
     is_same = namedpool.is_same_as(available_pool)
     self.assertTrue(is_same)
Exemple #2
0
def dosave(msg):
    if msg.entity == 'pool':
        #save the new named pool
        pool_type = name = url = user = priority = None
        for pair in msg.values:
            if 'pool_type' in pair:
                pool_type = pair['pool_type']
            if 'name' in pair:
                name = pair['name']
            if 'url' in pair:
                url = pair['url']
            if 'user' in pair:
                user = pair['user']
            if 'priority' in pair:
                priority = pair['priority']
        pool = Pool(pool_type, name, url, user, priority)
        sch = PoolSchema()
        pools = PoolRepository()
        pools.add(pool,
                  COMPONENTSAVE.app.getconfigfilename('config/pools.conf'),
                  sch)

        #update the known pools
        for known in COMPONENTSAVE.app.knownpools():
            if pool.is_same_as(known):
                oldkey = known.key
                known.named_pool = pool
                #this changes the pool key!
                known.user = pool.user
                #update the known pool (with new key)
                COMPONENTSAVE.app.update_pool(oldkey, known)
Exemple #3
0
 def p_same_as_partial_match_case(self):
     '''test'''
     namedpool = Pool('S9', 'CoolPool', 'tcp://stratum.pool.com',
                      'workername.', 0)
     available_pool = AvailablePool('S9', None, \
         'tcp://STRATUM.POOL.COM', 'workername.MinerName', 'x', 0)
     is_same = namedpool.is_same_as(available_pool)
     self.assertTrue(is_same)
Exemple #4
0
    def save_pool(self, pool: Pool):
        sch = PoolSchema()
        pools = PoolRepository()
        pools.add(pool, self.getconfigfilename('config/pools.conf'), sch)

        #update the known pools
        for known in self.knownpools():
            if pool.is_same_as(known):
                oldkey = known.key
                known.named_pool = pool
                #this changes the pool key!
                known.user = pool.user
                #update the known pool (with new key)
                self.update_pool(oldkey, known)
Exemple #5
0
 def test_pool_create(self):
     values = []
     values.append({"name": "UnitTest"})
     values.append({"pool_type": "unitpool"})
     values.append({"url": "unittest.com"})
     values.append({"user": "******"})
     values.append({"priority": "priority"})
     values.append({"password": "******"})
     pool = Pool.create(values)
     self.assertTrue(pool.name == "UnitTest")
     self.assertTrue(pool.pool_type == "unitpool")
     self.assertTrue(pool.url == "unittest.com")
     self.assertTrue(pool.user == "test")
     self.assertTrue(pool.priority == "priority")
     self.assertTrue(pool.password == "secret")
Exemple #6
0
def dosave(msg):
    entries = QueueEntries()
    if msg.entity == 'miner':
        #add or update miner
        minerid = name = ipaddress = port = None
        for pair in msg.values:
            if 'minerid' in pair:
                minerid = pair['minerid']
            if 'name' in pair:
                name = pair['name']
            if 'ipaddress' in pair:
                ipaddress = pair['ipaddress']
            if 'port' in pair:
                port = pair['port']
        miner = Miner(name, '', '', ipaddress, port, '', '')
        COMPONENTSAVE.app.save_miner(miner)
        entries.add(QueueName.Q_MONITORMINER,
                    COMPONENTSAVE.app.messageencode(miner))
        entries.add(QueueName.Q_PROVISION,
                    COMPONENTSAVE.app.messageencode(miner))

    if msg.entity == 'pool':
        #save the new named pool
        pool_type = name = url = user = priority = None
        for pair in msg.values:
            if 'pool_type' in pair:
                pool_type = pair['pool_type']
            if 'name' in pair:
                name = pair['name']
            if 'url' in pair:
                url = pair['url']
            if 'user' in pair:
                user = pair['user']
            if 'priority' in pair:
                priority = pair['priority']
        pool = Pool(pool_type, name, url, user, priority)
        COMPONENTSAVE.app.save_pool(pool)
    return entries
Exemple #7
0
def savepool(msg):
    #save the new named pool
    pool = Pool.create(msg.values)
    COMPONENTSAVE.app.pools.save_pool(pool)
    return pool
Exemple #8
0
'''test writing to config file'''
import json
from marshmallow import pprint
from domain.mining import Pool
from domain.rep import PoolRepository
from messaging.schema import PoolSchema

SCH = PoolSchema()
POOLS = PoolRepository()
SAVEDPOOLS = POOLS.readpools("backend/config/pools.conf")

POOL1 = Pool('Antminer 1', 'Name 1', 'http://url1', 'user1.', 1)
#pools.add(pool1,PoolSchema())
POOL2 = Pool('Antminer 2', 'Name 2', 'http://url2', 'user2.', 2)
#pools.add(pool2,PoolSchema())
SAVEDPOOLS.append(POOL1)
SAVEDPOOLS.append(POOL2)

JSON_POOLS = [SCH.dump(k).data for k in SAVEDPOOLS]

FORMATTED_JSON = json.dumps(JSON_POOLS,
                            sort_keys=True,
                            indent=4,
                            ensure_ascii=False)
pprint(FORMATTED_JSON)
input('any key')
Exemple #9
0
 def make(self, data):
     return Pool(**data)
Exemple #10
0
 def test_pool(self):
     sch = messaging.schema.PoolSchema()
     entity = Pool('', '', '', '', 1, '')
     j = sch.dumps(entity).data
     reentity = sch.loads(j).data
     self.assertTrue(isinstance(reentity, Pool))