Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to
    ContractReceiveChannelSettled.
163917
def _add_onchain_locksroot_to_channel_settled_state_changes(
        raiden: RaidenService,
        storage: SQLiteStorage,
) -> None:
    
    batch_size = 50
    batch_query = storage.batch_query_state_changes(
        batch_size=batch_size,
        filters=[
            ('_type', 'raiden.transfer.state_change.ContractReceiveChannelSettled'),
        ],
    )
    for state_changes_batch in batch_query:
        updated_state_changes = list()
        for state_change in state_changes_batch:
            state_change_data = json.loads(state_change.data)
            msg = 'v18 state changes cant contain our_onchain_locksroot'
            assert 'our_onchain_locksroot' not in state_change_data, msg

            msg = 'v18 state changes cant contain partner_onchain_locksroot'
            assert 'partner_onchain_locksroot' not in state_change_data, msg

            token_network_identifier = state_change_data['token_network_identifier']
            channel_identifier = state_change_data['channel_identifier']

            channel_new_state_change = _find_channel_new_state_change(
                storage=storage,
                token_network_address=token_network_identifier,
                channel_identifier=channel_identifier,
            )

            if not channel_new_state_change.data:
                raise RaidenUnrecoverableError(
                    f'Could not find the state change for channel {channel_identifier}, '
                    f'token network address: {token_network_identifier} being created. ',
                )

            channel_state_data = json.loads(channel_new_state_change.data)
            new_channel_state = channel_state_data['channel_state']

            canonical_identifier = CanonicalIdentifier(
                chain_identifier=-1,
                token_network_address=to_canonical_address(token_network_identifier),
                channel_identifier=int(channel_identifier),
            )
            our_locksroot, partner_locksroot = get_onchain_locksroots(
                chain=raiden.chain,
                canonical_identifier=canonical_identifier,
                participant1=to_canonical_address(new_channel_state['our_state']['address']),
                participant2=to_canonical_address(new_channel_state['partner_state']['address']),
                block_identifier='latest',
            )

            state_change_data['our_onchain_locksroot'] = serialize_bytes(
                our_locksroot,
            )
            state_change_data['partner_onchain_locksroot'] = serialize_bytes(
                partner_locksroot,
            )

            updated_state_changes.append((
                json.dumps(state_change_data),
                state_change.state_change_identifier,
            ))
        storage.update_state_changes(updated_state_changes)
1327448
protected void addSocketioHandlers(ChannelPipeline pipeline) {
        pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder());
        pipeline.addLast(HTTP_AGGREGATOR, new HttpObjectAggregator(configuration.getMaxHttpContentLength()) {
            @Override
            protected Object newContinueResponse(HttpMessage start, int maxContentLength,
                    ChannelPipeline pipeline) {
                return null;
            }

        });
        pipeline.addLast(HTTP_ENCODER, new HttpResponseEncoder());

        if (configuration.isHttpCompression()) {
            pipeline.addLast(HTTP_COMPRESSION, new HttpContentCompressor());
        }

        pipeline.addLast(PACKET_HANDLER, packetHandler);

        pipeline.addLast(AUTHORIZE_HANDLER, authorizeHandler);
        pipeline.addLast(XHR_POLLING_TRANSPORT, xhrPollingTransport);
        // TODO use single instance when https://github.com/netty/netty/issues/4755 will be resolved
        if (configuration.isWebsocketCompression()) {
            pipeline.addLast(WEB_SOCKET_TRANSPORT_COMPRESSION, new WebSocketServerCompressionHandler());
        }
        pipeline.addLast(WEB_SOCKET_TRANSPORT, webSocketTransport);

        pipeline.addLast(SOCKETIO_ENCODER, encoderHandler);

        pipeline.addLast(WRONG_URL_HANDLER, wrongUrlHandler);
    }
402331
def attach(self, gui):
        """"""
        super(FeatureView, self).attach(gui)
        self.actions.add(self.increase)
        self.actions.add(self.decrease)
        self.actions.separator()
        self.actions.add(self.clear_channels)
        self.actions.add(self.toggle_automatic_channel_selection)

        gui.connect_(self.on_channel_click)
        gui.connect_(self.on_request_split)
751046
void addTransaction(Transaction t, boolean runSanityChecks) {
        unCacheTransactions();
        if (transactions == null) {
            transactions = new ArrayList<>();
        }
        t.setParent(this);
        if (runSanityChecks && transactions.size() == 0 && !t.isCoinBase())
            throw new RuntimeException("Attempted to add a non-coinbase transaction as the first transaction: " + t);
        else if (runSanityChecks && transactions.size() > 0 && t.isCoinBase())
            throw new RuntimeException("Attempted to add a coinbase transaction when there already is one: " + t);
        transactions.add(t);
        adjustLength(transactions.size(), t.length);
        // Force a recalculation next time the values are needed.
        merkleRoot = null;
        hash = null;
    }
625760
public synchronized void addProtocol(String productString, ChannelListener<? super StreamConnection> openListener, final HttpUpgradeHandshake handshake) {
        addProtocol(productString, null, openListener, handshake);
    }
1362258
@Trivial
    protected void setSslSupport(ServiceReference<ChannelFactoryProvider> ref) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.entry(this, tc, "setSslSupport", new Object[] { ref.getProperty("type"), ref });
        }

        // If sslsupport is bound then set it to true 
        _isSSLEnabled = true;

        // bind can get called before unbind for new config/ modify.Hence the precaution
        if (_sslFactoryProvider.getReference() != null) { // existing chain is still there so destroy 
            if (_isChainStarted)
                performAction(destroyChainAction);
        }

        _sslFactoryProvider.setReference(ref);
        // we will only invoke createchain if 
        // 1) activate() is complete
        // this is because bind method get called first before activate and without activate we don't have any properties
        // 2) if useSSL is set in config 
        if (_isActivated && _isSSLChain) {
            //TODO: when executor service is used for performaction() make sure about sequence of destroy and create chain
            //Now currently its not threaded
            if (_isChainStarted)
                performAction(destroyChainAction);
            performAction(createChainAction);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "setSslSupport", _isSSLEnabled);
        }
    }
153956
def _sync_and_resolve(self, config, resolver):
        ''''''
        resolved = set()
        for key, theirs in config.items(self._name):
            theirs = self._real_value_of(theirs)
            if key in self:
                mine = self[key]
                value = resolver(self._name, key, mine, theirs)
            else:
                value = theirs
            self._set_value(config, key, value)
            resolved.add(key)
        return resolved
534893
public void addAndActivateHDChain(DeterministicKeyChain chain) {
        checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
        log.info("Activating a new HD chain: {}", chain);
        for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners())
            chain.addEventListener(registration.listener, registration.executor);
        if (lookaheadSize >= 0)
            chain.setLookaheadSize(lookaheadSize);
        if (lookaheadThreshold >= 0)
            chain.setLookaheadThreshold(lookaheadThreshold);
        chains.add(chain);
        currentKeys.clear();
        currentAddresses.clear();
    }
1217506
public void addMEToRemoteQueuePointGuessSet(SIBUuid8 messagingEngineUuid)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "addMEToRemoteQueuePointGuessSet");

    synchronized (_remoteQueuePointsGuessSet)
    {
      _remoteQueuePointsGuessSet.add(messagingEngineUuid);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "addMEToRemoteQueuePointGuessSet");
  }
735310
@Override
    public synchronized ChainData addChain(String chainName, FlowType chainType, String[] channelNameList) throws ChannelException, ChainException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "addChain: " + chainName);
        }
        if (null == chainName) {
            throw new InvalidChainNameException("Input chain name is null");
        }
        if (null == channelNameList || 0 == channelNameList.length) {
            throw new InvalidChannelNameException("Invalid channel list");
        }

        ChainDataImpl chainData = chainDataMap.get(chainName);
        // Ensure the chain name doesn't already exist in the framework.
        if (null != chainData) {
            InvalidChainNameException e = new InvalidChainNameException("Chain config already exists, " + chainName);
            FFDCFilter.processException(e, getClass().getName() + ".addChain", "1411", this, new Object[] { chainData });
            throw e;
        }

        int zRegion = RegionType.NOT_ON_Z;
        boolean okToAdd = true;
        ChannelFactory factory = null;

        // Determine if we are running on Z, and if so, what region we are in
        if (currentlyOnZ()) {
            zRegion = currentZRegion();
        }

        // Ensure each of the channel configurations already exist in the framework.
        ChannelData[] channelDataArray = new ChannelData[channelNameList.length];
        ChannelData channelData = null;
        int i = 0;
        int lastIndex = channelNameList.length - 1;
        for (i = 0; i <= lastIndex; i++) {
            factory = null;
            channelData = channelDataMap.get(channelNameList[i]);
            if (null == channelData) {
                InvalidChannelNameException e = new InvalidChannelNameException("Can't add chain config due to unknown channel, " + channelNameList[i]);
                FFDCFilter.processException(e, getClass().getName() + ".addChain", "1443", this, new Object[] { channelNameList[i] });
                throw e;
            }
            if (zRegion != RegionType.NOT_ON_Z && chainType.equals(FlowType.INBOUND)) {
                // On Z and inbound, need to do some special Z things
                if (i == lastIndex) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "On Z, looking at Application Channel, " + channelData.getName());
                    }
                    // Looking at the Inbound Application Channel
                    factory = getChannelFactoryInternal(channelData.getFactoryType(), false);

                    if (zRegion == RegionType.SR_REGION) {
                        // in SR, check if we should start this chain
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Operating in Servant Region");
                        }
                        if (factory instanceof BoundRegion) {
                            if (!(((BoundRegion) factory).isServantStartable(channelDataMap))) {
                                // channel does not want to start given the current
                                // configuration
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(tc, "Channel says it is not startable in Servant Region");
                                }
                                okToAdd = false;
                            }
                        }
                    } else if ((zRegion == BoundRegion.CR_REGION) || (zRegion == BoundRegion.CRA_REGION)) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Operating in CR or CRA Region, Region constant: " + zRegion);
                        }
                        // In a secure region. check if the channel implements BoundRegion,
                        // and is configured to run in this region
                        if (factory instanceof BoundRegion) {
                            if (zRegion != (((BoundRegion) factory).getRegion(channelDataMap))) {
                                // channel does not support running in this region
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(tc, "This Channel says it is not startable in this Region: getRegion returned: " + ((BoundRegion) factory).getRegion(channelDataMap));
                                }
                                okToAdd = false;
                            }
                        }
                    }
                } else {
                    // Not Looking at an application channel in the chain
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "On Z, looking at non-application Channel, " + channelData.getName());
                    }

                    if ((zRegion == BoundRegion.CR_REGION) || (zRegion == BoundRegion.CRA_REGION)) {
                        // mark what region this channel is being asked to run in, and
                        // log a warning if this gives a sharable problem
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Operating in CR or CRA Region, Region constant: " + zRegion);
                        }

                        // Get Channel entry from HashMap
                        Integer channelEntry = ChannelZRegions.get(channelData.getName());
                        if (channelEntry == null) {
                            // new entry
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "First time setting region entry for this channel");
                            }
                            ChannelZRegions.put(channelData.getName(), Integer.valueOf(zRegion));
                        } else {
                            // check to see if we are being asked to run in a different region
                            int entryValue = channelEntry.intValue();

                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "Not first time setting region entry for this channel, current region entry is: " + entryValue);
                            }

                            if ((entryValue & zRegion) == 0) {
                                // being asked to be run in a different region, see if this is
                                // sharable
                                factory = getChannelFactoryInternal(channelData.getFactoryType(), false);
                                if (factory instanceof CrossRegionSharable) {
                                    if (!(((CrossRegionSharable) factory).isSharable(channelDataMap))) {
                                        // non-sharable channel is being put into different regions
                                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                            Tr.debug(tc, "Channel says it is not sharable");
                                        }
                                        Tr.warning(tc, "channel.shared.warning", new Object[] { channelData.getName() });

                                    }
                                }
                                // update regions that this channel is being used in
                                ChannelZRegions.put(channelData.getName(), Integer.valueOf(entryValue | zRegion));
                            }
                        }
                    }
                }
            }
            channelDataArray[i] = channelData;
        } // end-for loop on channels

        if (okToAdd) {
            try {
                // Store values for the host and port in the chain if it is inbound.
                Map<Object, Object> chainProperties = null;
                if (FlowType.INBOUND.equals(chainType)) {
                    chainProperties = new HashMap<Object, Object>();
                    Map<Object, Object> tcpProperties = channelDataArray[0].getPropertyBag();
                    chainProperties.put(ChannelFrameworkConstants.HOST_NAME, tcpProperties.get(ChannelFrameworkConstants.HOST_NAME));
                    chainProperties.put(ChannelFrameworkConstants.PORT, tcpProperties.get(ChannelFrameworkConstants.PORT));
                    chainProperties.put(ChannelFrameworkConstants.LISTENING_PORT, tcpProperties.get(ChannelFrameworkConstants.LISTENING_PORT));
                }
                chainData = (ChainDataImpl) createChainData(chainName, chainType, channelDataArray, chainProperties);
                // Add the new chain to the framework configuration.
                this.chainDataMap.put(chainName, chainData);
                // Associate any global chain event listeners.
                for (int j = 0; j < globalChainEventListeners.size(); j++) {
                    chainData.addChainEventListener(globalChainEventListeners.get(j));
                }
            } catch (IncoherentChainException e) {
                FFDCFilter.processException(e, getClass().getName() + ".addChain", "1601", this, new Object[] { chainName, chainType, channelDataArray });
                throw e;
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "addChain");
        }
        return chainData;
    }
1002509
function commit_tunnel() {
            tunnel.onstatechange = chained_tunnel.onstatechange;
            tunnel.oninstruction = chained_tunnel.oninstruction;
            tunnel.onerror = chained_tunnel.onerror;
            chained_tunnel.uuid = tunnel.uuid;
            committedTunnel = tunnel;
        }
344378
function addNonConflicted(sourceNode, callback) {
    conflict.isConflictedCopy(fs, sourceNode.path, function(err, conflicted) {
      if(err) {
        return callback(err);
      }

      if(!conflicted) {
        sources.push(sourceNode);
      }

      callback(null, sources);
    });
  }
764474
public void enlistWithTransaction(SynchronizationRegistryUOWScope uowCoord,
                                      Synchronization sync)
                    throws CSIException
    {
        try
        {
            if (uowCoord.getUOWType() == UOWSynchronizationRegistry.UOW_TYPE_GLOBAL_TRANSACTION)
            {
                ((Transaction) uowCoord).registerSynchronization(sync);
            }
            else
            {
                ((LocalTransactionCoordinator) uowCoord).enlistSynchronization(sync);
            }
        } catch (Exception ex)
        {
            throw new CSIException("Failed to enlist with transaction", ex);
        }
    }
331065
@Override
  public void onToken(Context context, String token, Bundle bundle) {
    updateAVInstallation(token);
  }
1164760
def on_connect(self, connection):
        ""
        # NOTE: for python3, we can't pass bytestrings as keyword arguments
        # so we need to decode channel/pattern names back to unicode strings
        # before passing them to [p]subscribe.
        self.pending_unsubscribe_channels.clear()
        self.pending_unsubscribe_patterns.clear()
        if self.channels:
            channels = {}
            for k, v in iteritems(self.channels):
                channels[self.encoder.decode(k, force=True)] = v
            self.subscribe(**channels)
        if self.patterns:
            patterns = {}
            for k, v in iteritems(self.patterns):
                patterns[self.encoder.decode(k, force=True)] = v
            self.psubscribe(**patterns)
920323
def AddContract(self, contract):
        
        if not contract.PublicKeyHash.ToBytes() in self._keys.keys():
            raise Exception('Invalid operation - public key mismatch')

        self._contracts[contract.ScriptHash.ToBytes()] = contract
        if contract.ScriptHash in self._watch_only:
            self._watch_only.remove(contract.ScriptHash)
1144894
void trySetTrustAnchor(TrustAnchor anchor) {
        // Don't bother if the check has started or trust anchor has already
        // specified.
        if (prevPubKey == null) {
            if (anchor == null) {
                throw new IllegalArgumentException(
                        "The trust anchor cannot be null");
            }

            // Don't bother to change the trustedPubKey.
            if (anchor.getTrustedCert() != null) {
                prevPubKey = anchor.getTrustedCert().getPublicKey();
            } else {
                prevPubKey = anchor.getCAPublicKey();
            }
        }
    }