예제 #1
0
def marduk(factoryInstance, committerInstance):
    if globals.appIsPaused:  # If the app is explicitly paused, don't create active network events.
        return

    d3 = Demeter.getNodesToConnect(globals.maxOutboundCount, globals.cooldown)
    print('max outbound count:', globals.maxOutboundCount, 'cooldown:',
          globals.cooldown)

    def connectToNodes(nodes, openConnsList):
        if len(nodes) == 0:
            # If this is a bootstrap.
            global firstConnectTriggered
            if not firstConnectTriggered and (globals.newborn or globals.nuked
                                              or globals.resetted):
                firstConnectTriggered = True
                print('We\'re bootstrapping!')
                connectWithIP('151.236.11.192', 39994)  # austria #FIXME 39994
            else:
                print('There are no nodes to connect to!')
                print('Number of open connections:', len(openConnsList),
                      'Commit in Progress: ',
                      committerInstance.commitInProgress)
                if not len(openConnsList
                           ) and not committerInstance.commitInProgress:
                    connectWithIP('151.236.11.192',
                                  39994)  # austria #FIXME 39994

        for n in nodes:
            print('I\'m attempting to connect to node %s at %s:%s' %
                  (n.NodeId, n.LastConnectedIP if n.LastConnectedIP is not None
                   else n.LastRetrievedIP, n.LastConnectedPort if
                   n.LastConnectedPort is not None else n.LastRetrievedPort))
            connectWithNode(n.asDict())

    d3.addCallback(connectToNodes, factoryInstance.openConnections)
예제 #2
0
def marduk(factoryInstance, committerInstance):
    if globals.appIsPaused: # If the app is explicitly paused, don't create active network events.
        return

    d3 = Demeter.getNodesToConnect(maxOutboundCount, cooldown)
    print('max outbound count:', maxOutboundCount, 'cooldown:', cooldown)
    def connectToNodes(nodes, openConnsList):
        # if not committerInstance.commitInProgress: # Don't connect outbound if a commit is in progress.
        if len(nodes) == 0:
            print('There are no nodes to connect to!')
            lastBareIP = globals.userProfile.get('machineDetails', 'lastConnectedBareIP')
            lastBarePort = globals.userProfile.get('machineDetails', 'lastConnectedBarePort')
            if isinstance(lastBarePort, int) and isinstance(lastBareIP, basestring) and \
                            lastBarePort != 0 and not Demeter.committer.commitInProgress:
            # Only connect if there is a bare connection request before and there is no commit in progress.
            # This is to prevent the first connection repeatedly calling over and wasting bandwidth while he has
            # everything in memory, just committing.
                print('Reaching out to the last bare '
                      'connect attempt at %s : %s' % (lastBareIP, lastBarePort))
                connectWithIP(lastBareIP, lastBarePort)
            else:
                print('This computer has never bare-connected to another node or a commit is in progress. '
                      'This usually means onboarding is not completed. lastBarePort = %s, commitInProgress = %s' %
                      (lastBarePort, Demeter.committer.commitInProgress))
        print('Number of open connections:', len(openConnsList))
        for n in nodes:
             print('I\'m attempting to connect to node %s at %s:%s'
                   %(n.NodeId,
                     n.LastConnectedIP if n.LastConnectedIP is not None else n.LastRetrievedIP,
                     n.LastConnectedPort if n.LastConnectedPort is not None else n.LastRetrievedPort))
             connectWithNode(n.asDict())
        # else:
        #     print('A commit is in progress. Skipping this round of marduk.')
    d3.addCallback(connectToNodes, factoryInstance.openConnections)
예제 #3
0
def marduk(factoryInstance, committerInstance):
    if globals.appIsPaused: # If the app is explicitly paused, don't create active network events.
        return

    d3 = Demeter.getNodesToConnect(globals.maxOutboundCount, globals.cooldown)
    print('max outbound count:', globals.maxOutboundCount, 'cooldown:', globals.cooldown)
    def connectToNodes(nodes, openConnsList):
        if len(nodes) == 0:
            # If this is a bootstrap.
            global firstConnectTriggered
            if not firstConnectTriggered and (globals.newborn or globals.nuked or globals.resetted):
                firstConnectTriggered = True
                print('We\'re bootstrapping!')
                connectWithIP('151.236.11.192', 39994) # austria #FIXME 39994
            else:
                print('There are no nodes to connect to!')
                print('Number of open connections:', len(openConnsList), 'Commit in Progress: ', committerInstance.commitInProgress)
                if not len(openConnsList) and not committerInstance.commitInProgress:
                    connectWithIP('151.236.11.192', 39994) # austria #FIXME 39994

        for n in nodes:
             print('I\'m attempting to connect to node %s at %s:%s'
                   %(n.NodeId,
                     n.LastConnectedIP if n.LastConnectedIP is not None else n.LastRetrievedIP,
                     n.LastConnectedPort if n.LastConnectedPort is not None else n.LastRetrievedPort))
             connectWithNode(n.asDict())
    d3.addCallback(connectToNodes, factoryInstance.openConnections)
예제 #4
0
def marduk():
    if globals.appIsPaused: # If the app is explicitly paused, don't create active network events.
        return

    d3 = Demeter.getNodesToConnect(10, 0)
    def connectToNodes(nodes):
        if len(nodes) == 0 and (globals.newborn or globals.nuked):
        # If there is only the local node, that means no one to connect to.
            print('There are no nodes to connect to!')
            connectWithIP('151.236.11.192', 39994) # austria
        for n in nodes:
             print('I\'m attempting to connect to node %s at %s:%s'
                   %(n.NodeId,
                     n.LastConnectedIP if n.LastConnectedIP is not None else n.LastRetrievedIP,
                     n.LastConnectedPort if n.LastConnectedPort is not None else n.LastRetrievedPort))
             connectWithNode(n.asDict())
    d3.addCallback(connectToNodes)
예제 #5
0
def marduk(factoryInstance, committerInstance):
    if globals.appIsPaused:  # If the app is explicitly paused, don't create active network events.
        return

    d3 = Demeter.getNodesToConnect(maxOutboundCount, cooldown)
    print('max outbound count:', maxOutboundCount, 'cooldown:', cooldown)

    def connectToNodes(nodes, openConnsList):
        # if not committerInstance.commitInProgress: # Don't connect outbound if a commit is in progress.
        if len(nodes) == 0:
            print('There are no nodes to connect to!')
            lastBareIP = globals.userProfile.get('machineDetails',
                                                 'lastConnectedBareIP')
            lastBarePort = globals.userProfile.get('machineDetails',
                                                   'lastConnectedBarePort')
            if isinstance(lastBarePort, int) and isinstance(lastBareIP, basestring) and \
                            lastBarePort != 0 and not Demeter.committer.commitInProgress:
                # Only connect if there is a bare connection request before and there is no commit in progress.
                # This is to prevent the first connection repeatedly calling over and wasting bandwidth while he has
                # everything in memory, just committing.
                print('Reaching out to the last bare '
                      'connect attempt at %s : %s' %
                      (lastBareIP, lastBarePort))
                connectWithIP(lastBareIP, lastBarePort)
            else:
                print(
                    'This computer has never bare-connected to another node or a commit is in progress. '
                    'This usually means onboarding is not completed. lastBarePort = %s, commitInProgress = %s'
                    % (lastBarePort, Demeter.committer.commitInProgress))
        print('Number of open connections:', len(openConnsList))
        for n in nodes:
            print('I\'m attempting to connect to node %s at %s:%s' %
                  (n.NodeId, n.LastConnectedIP if n.LastConnectedIP is not None
                   else n.LastRetrievedIP, n.LastConnectedPort if
                   n.LastConnectedPort is not None else n.LastRetrievedPort))
            connectWithNode(n.asDict())
        # else:
        #     print('A commit is in progress. Skipping this round of marduk.')

    d3.addCallback(connectToNodes, factoryInstance.openConnections)