Ejemplo n.º 1
0
 def __init__(self, options, config):
     """Initializes all of the submodules bitHopper uses"""
     
     #Logging
     
     logging.basicConfig(stream=sys.stdout, format="%(asctime)s|%(module)s: %(message)s", datefmt="%H:%M:%S", level = logging.INFO)
     
     self.options = options
     self.config = config        
     altercoins = ConfigParser.ConfigParser()
     altercoins.read(os.path.join(sys.path[0], "whatevercoin.cfg"))
     self.altercoins = {}
     for coin in altercoins.sections():
         self.altercoins[coin] = dict(altercoins.items(coin))
         self.altercoins[coin]['recent_difficulty'] = float(self.altercoins[coin]['recent_difficulty'])
     self.scheduler = None
     self.lp_callback = lp_callback.LP_Callback(self)
     self.difficulty = diff.Difficulty(self)  
     self.exchange = exchange.Exchange(self)
     self.pool = None        
     self.db = database.Database(self)                       
     self.pool = pool.Pool_Parse(self)
     self.api = api.API(self) 
     self.pool.setup(self)
     self.work = work.Work(self)
     self.speed = speed.Speed()
     self.getwork_store = getwork_store.Getwork_store(self)
     self.data = data.Data(self)       
     self.lp = lp.LongPoll(self)
     self.auth = None
     
     self.website = website.bitSite(self)
     self.plugin = plugin.Plugin(self)
     gevent.spawn(self.delag_server)
Ejemplo n.º 2
0
 def __init__(self, options, config):
     """Initializes all of the submodules bitHopper uses"""
     
     #Logging
     
     logging.basicConfig(stream=sys.stdout, format="%(asctime)s|%(module)s: %(message)s", datefmt="%H:%M:%S", level = logging.INFO)
     
     self.options = options
     self.config = config        
     altercoins = ConfigParser.ConfigParser()
     altercoins.read(os.path.join(sys.path[0], "whatevercoin.cfg"))
     self.altercoins = {}
     for coin in altercoins.sections():
         self.altercoins[coin] = dict(altercoins.items(coin))
         self.altercoins[coin]['recent_difficulty'] = float(self.altercoins[coin]['recent_difficulty'])
     self.scheduler = None
     self.lp_callback = lp_callback.LP_Callback(self)
     self.difficulty = diff.Difficulty(self)  
     self.exchange = exchange.Exchange(self)
     self.pool = None        
     self.db = database.Database(self)                       
     self.pool = pool.Pool_Parse(self)
     self.api = api.API(self) 
     self.pool.setup(self)
     self.work = work.Work(self)
     self.speed = speed.Speed()
     self.getwork_store = getwork_store.Getwork_store(self)
     self.data = data.Data(self)       
     self.lp = lp.LongPoll(self)
     self.auth = None
     
     self.website = website.bitSite(self)
     self.pile = greenpool.GreenPool()
     self.plugin = plugin.Plugin(self)
     self.pile.spawn_n(self.delag_server)
Ejemplo n.º 3
0
 def __init__(self, options, config):
     """Initializes all of the submodules bitHopper uses"""
     self.options = options
     self.config = config        
     altercoins = ConfigParser.ConfigParser()
     altercoins.read(os.path.join(sys.path[0], "whatevercoin.cfg"))
     self.altercoins = {}
     for coin in altercoins.sections():
         self.altercoins[coin] = dict(altercoins.items(coin))
         self.altercoins[coin]['recent_difficulty'] = float(self.altercoins[coin]['recent_difficulty'])
     self.scheduler = None
     self.lp_callback = lp_callback.LP_Callback(self)
     self.difficulty = diff.Difficulty(self)  
     self.exchange = exchange.Exchange(self)
     self.pool = None        
     self.db = database.Database(self)                       
     self.pool = pool.Pool_Parse(self)
     self.api = api.API(self) 
     self.pool.setup(self)
     self.work = work.Work(self)
     self.speed = speed.Speed(self)
     self.getwork_store = getwork_store.Getwork_store(self)
     self.data = data.Data(self)       
     self.lp = lp.LongPoll(self)
     self.auth = None
     
     self.website = website.bitSite(self)
     self.pile = greenpool.GreenPool()
     self.plugin = plugin.Plugin(self)
     self.pile.spawn_n(self.delag_server)
Ejemplo n.º 4
0
 def __init__(self, options):
     """Initializes all of the submodules bitHopper uses"""
     self.options = options
     self.lp_callback = lp_callback.LP_Callback(self)
     self.lpBot = None
     self.difficulty = diff.Difficulty(self)           
     self.pool = pool.Pool(self)     
     self.db = database.Database(self)
     self.pool.setup(self) 
     self.speed = speed.Speed(self)
     self.scheduler = scheduler.Scheduler(self)
     self.getwork_store = getwork_store.Getwork_store(self)
     self.data = data.Data(self)       
     self.lp = lp.LongPoll(self)
     self.auth = None
     self.work = work.Work(self)
     self.website = website.bitSite(self)
     self.plugin = plugin.Plugin(self)
     self.pile = greenpool.GreenPool()
     self.pile.spawn_n(self.delag_server)
Ejemplo n.º 5
0
def main():
    parser = optparse.OptionParser(description='bitHopper')
    parser.add_option('--noLP', action = 'store_true' ,default=False, help='turns off client side longpolling')
    parser.add_option('--debug', action= 'store_true', default = False, help='Use twisted output')
    parser.add_option('--listschedulers', action='store_true', default = False, help='List alternate schedulers available')
    parser.add_option('--list', action= 'store_true', default = False, help='List servers')
    parser.add_option('--disable', type=str, default = None, action='callback', callback=parse_server_disable, help='Servers to disable. Get name from --list. Servera,Serverb,Serverc')
    parser.add_option('--port', type = int, default=8337, help='Port to listen on')
    parser.add_option('--scheduler', type=str, default=None, help='Select an alternate scheduler')
    parser.add_option('--threshold', type=float, default=None, help='Override difficulty threshold (default 0.43)')
    parser.add_option('--altslicesize', type=int, default=900, help='Override Default AltSliceScheduler Slice Size of 900')
    parser.add_option('--altminslicesize', type=int, default=60, help='Override Default Minimum Pool Slice Size of 60 (AltSliceScheduler only)')
    parser.add_option('--altslicejitter', type=int, default=0, help='Add some random variance to slice size, disabled by default (AltSliceScheduler only)')
    parser.add_option('--startLP', action= 'store_true', default = False, help='Seeds the LP module with known pools. Must use it for LP based hopping with deepbit')
    args, rest = parser.parse_args()
    options = args
    bithopper_global.options = args

    if options.list:
        for k in bithopper_global.pool.get_servers():
            print k
        return

    if options.listschedulers:
        schedulers = None
        for s in Scheduler.__subclasses__():
            if schedulers != None: schedulers = schedulers + ", " + s.__name__
            else: schedulers = s.__name__
        print "Available Schedulers: " + schedulers
        return
    
    if options.scheduler:
        bithopper_global.log_msg("Selecting scheduler: " + options.scheduler)
        foundScheduler = False
        for s in Scheduler.__subclasses__():
            if s.__name__ == options.scheduler:
                bithopper_global.scheduler = s(bithopper_global)
                foundScheduler = True
                break
        if foundScheduler == False:            
            bithopper_global.log_msg("Error couldn't find: " + options.scheduler + ". Using default scheduler.")
            bithopper_global.scheduler = scheduler.DefaultScheduler(bithopper_global)
    else:
        bithopper_global.log_msg("Using default scheduler.")
        bithopper_global.scheduler = scheduler.DefaultScheduler(bithopper_global)

    bithopper_global.select_best_server()

    if options.disable != None:
        for k in options.disable:
            if k in bithopper_global.pool.get_servers():
                if bithopper_global.pool.get_servers()[k]['role'] == 'backup':
                    bithopper_global.log_msg("You just disabled the backup pool. I hope you know what you are doing")
                bithopper_global.pool.get_servers()[k]['role'] = 'disable'
            else:
                bithopper_global.log_msg(k + " Not a valid server")

    if options.debug: log.startLogging(sys.stdout)

    if options.startLP:
        bithopper_global.log_msg( 'Starting LP')
        startlp = LoopingCall(bithopper_global.lp.start_lp)
        startlp.start(60*30)

    site = server.Site(website.bitSite(bithopper_global))
    reactor.listenTCP(options.port, site)
    reactor.callLater(0, bithopper_global.pool.update_api_servers, bithopper_global)
    delag_call = LoopingCall(bithopper_global.delag_server)
    delag_call.start(119)
    reactor.run()
    bithopper_global.db.close()
Ejemplo n.º 6
0
def main():
    parser = optparse.OptionParser(description='bitHopper')
    parser.add_option('--debug', action= 'store_true', default = False, help='Log twisted output')
    parser.add_option('--trace', action= 'store_true', default = False, help='Extra debugging output')
    parser.add_option('--listschedulers', action='store_true', default = False, help='List alternate schedulers available')
    parser.add_option('--port', type = int, default=8337, help='Port to listen on')
    parser.add_option('--scheduler', type=str, default=None, help='Select an alternate scheduler')
    parser.add_option('--threshold', type=float, default=None, help='Override difficulty threshold (default 0.43)')
    parser.add_option('--altslicesize', type=int, default=900, help='Override Default AltSliceScheduler Slice Size of 900')
    parser.add_option('--altminslicesize', type=int, default=60, help='Override Default Minimum Pool Slice Size of 60 (AltSliceScheduler only)')
    parser.add_option('--altslicejitter', type=int, default=0, help='Add some random variance to slice size, disabled by default (AltSliceScheduler only)')
    parser.add_option('--altsliceroundtimebias', action='store_true', default=False, help='Bias slicing slightly by round time duration with respect to round time target (default false)')
    parser.add_option('--altsliceroundtimetarget', type=int, default=1000, help='Round time target based on GHash/s (default 1000 Ghash/s)')
    parser.add_option('--altsliceroundtimemagic', type=int, default=10, help='Round time magic number, increase to bias towards round time over shares')
    parser.add_option('--p2pLP', action='store_true', default=False, help='Starts up an IRC bot to validate LP based hopping.')
    parser.add_option('--OldConnectionSystem', action='store_true', default=False, help='Uses the old connection system. May help with lots of miners')
    parser.add_option('--ip', type = str, default='', help='IP to listen on')
    parser.add_option('--auth', type = str, default=None, help='User,Password')
    options = parser.parse_args()[0]

    if options.trace == True: options.debug = True

    if options.listschedulers:
        schedulers = ""
        for s in scheduler.Scheduler.__subclasses__():
            schedulers += ", " + s.__name__
        print "Available Schedulers: " + schedulers[2:]
        return

    bithopper_instance = BitHopper(options)

    if options.auth:
        auth = options.auth.split(',')
        bithopper_instance.auth = auth
        if len(auth) != 2:
            print 'User,Password. Not whatever you just entered'
            return
    
    if options.scheduler:
        bithopper_instance.log_msg("Selecting scheduler: " + options.scheduler)
        foundScheduler = False
        for s in Scheduler.__subclasses__():
            if s.__name__ == options.scheduler:
                bithopper_instance.scheduler = s(bithopper_instance)
                foundScheduler = True
                break
        if not foundScheduler:            
            bithopper_instance.log_msg("Error couldn't find: " + options.scheduler + ". Using default scheduler.")
            bithopper_instance.scheduler = scheduler.DefaultScheduler(bithopper_instance)
    else:
        bithopper_instance.log_msg("Using default scheduler.")
        bithopper_instance.scheduler = scheduler.DefaultScheduler(bithopper_instance)

    bithopper_instance.select_best_server()

    if options.debug: 
        log.startLogging(sys.stdout)

    if options.p2pLP:
        bithopper_instance.log_msg('Starting p2p LP')
        bithopper_instance.lpBot = LpBot(bithopper_instance)

    site = server.Site(website.bitSite(bithopper_instance))
    reactor.listenTCP(options.port, site, 20, options.ip)
    reactor.run()
    bithopper_instance.db.close()