Passed
Push — master ( e21377...5956eb )
by Dave
01:06
created

domain.services.poolstoadd()   B

Complexity

Conditions 6

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 8
nop 3
dl 0
loc 11
rs 8.6666
c 0
b 0
f 0
1
'''#domain services layer'''
2
3
#operations are use cases
4
5
def poolstoadd(miner, minerpool, poollist):
6
    '''find pools that miner does not have'''
7
    poolsneeded = []
8
    #loop through pools for miner type
9
    for pool in poollist:
10
        if miner.minerinfo.miner_type.startswith(pool.pool_type) and pool.url is not None and pool.url != "":
11
            #if miner does not have pool configured
12
            foundpool = findpool(minerpool, pool)
13
            if foundpool is None:
14
                poolsneeded.append(pool)
15
    return poolsneeded
16
17
def findpool(minerpool, pool):
18
            foundpool = None
19
            jpools = minerpool.allpools["POOLS"]
20
            for existingpool in jpools:
21
                if pool.url == existingpool["URL"] and existingpool["User"].startswith(pool.user):
22
                    foundpool = existingpool
23