Merge any newly received txns during catchup with already received txns
        :param existing_txns:
        :param new_txns:
        :return:
169206
def _merge_catchup_txns(existing_txns, new_txns):
        
        # TODO: Can we replace this with SortedDict and before merging substract existing transactions from new?
        idx_to_remove = []
        start_seq_no = new_txns[0][0]
        end_seq_no = new_txns[-1][0]
        for seq_no, _ in existing_txns:
            if seq_no < start_seq_no:
                continue
            if seq_no > end_seq_no:
                break
            idx_to_remove.append(seq_no - start_seq_no)
        for idx in reversed(idx_to_remove):
            new_txns.pop(idx)

        return list(merge(existing_txns, new_txns, key=lambda v: v[0]))
398502
def merge_values(src, new):
    """"""
    if isinstance(src, dict) and isinstance(new, dict):
        return merge_dicts(src, new)
    else:
        if not isinstance(src, list):
            src = [src]
        if not isinstance(new, list):
            new = [new]

        return merge_lists(src, new)
567267
private void mergeEntryWithoutSplit(Node node,
            Entry newEntry, long timestamp) {

        Entry nearestEntryToCarriedBuffer =
                node.nearestEntry(newEntry);
        double distanceNearestEntryToBuffer =
                nearestEntryToCarriedBuffer.calcDistance(newEntry);

        BestMergeInNode bestMergeInNode =
                calculateBestMergeInNode(node);

        if (distanceNearestEntryToBuffer < bestMergeInNode.distance) {
            nearestEntryToCarriedBuffer.aggregateEntry(newEntry, timestamp,
                    this.negLambda);
        } else {
            node.mergeEntries(bestMergeInNode.entryPos1,
                    bestMergeInNode.entryPos2);
            node.addEntry(newEntry, timestamp);
        }
    }
804730
public static InventoryMessage with(Transaction... txns) {
        checkArgument(txns.length > 0);
        InventoryMessage result = new InventoryMessage(txns[0].getParams());
        for (Transaction tx : txns)
            result.addTransaction(tx);
        return result;
    }
728882
def new_transaction(options = {})
      options = options.dup

      options.merge!({
        :pos_id => @pos_id,
        :pos_auth_key => @pos_auth_key,
        :gateway_url => options[:gateway_url] || @gateway_url,
        :key1 => @key1,
        :encoding => encoding,
        :variant => variant
      })

      if !options.has_key?(:add_signature)
        options[:add_signature] = add_signature?
      end

      if !options.has_key?(:pay_type)
        options[:pay_type] = test_payment? ? 't' : nil
      end

      Transaction.new(options)
    end
463685
def deliver_tx(self, raw_transaction):
        

        self.abort_if_abci_chain_is_not_synced()

        logger.debug('deliver_tx: %s', raw_transaction)
        transaction = self.bigchaindb.is_valid_transaction(
            decode_transaction(raw_transaction), self.block_transactions)

        if not transaction:
            logger.debug('deliver_tx: INVALID')
            return ResponseDeliverTx(code=CodeTypeError)
        else:
            logger.debug('storing tx')
            self.block_txn_ids.append(transaction.id)
            self.block_transactions.append(transaction)
            return ResponseDeliverTx(code=CodeTypeOk)
56708
def merge_results(old_results, new_results):
    
    for filename, old_secrets in old_results.items():
        if filename not in new_results:
            continue

        old_secrets_mapping = dict()
        for old_secret in old_secrets:
            old_secrets_mapping[old_secret['hashed_secret']] = old_secret

        for new_secret in new_results[filename]:
            if new_secret['hashed_secret'] not in old_secrets_mapping:
                # We don't join the two secret sets, because if the newer
                # result set did not discover an old secret, it probably
                # moved.
                continue

            old_secret = old_secrets_mapping[new_secret['hashed_secret']]
            # Only propagate 'is_secret' if it's not already there
            if 'is_secret' in old_secret and 'is_secret' not in new_secret:
                new_secret['is_secret'] = old_secret['is_secret']

    return new_results
1091656
def _mark_received(self, tsn):
        
        # it's a duplicate
        if uint32_gte(self._last_received_tsn, tsn) or tsn in self._sack_misordered:
            self._sack_duplicates.append(tsn)
            return True

        # consolidate misordered entries
        self._sack_misordered.add(tsn)
        for tsn in sorted(self._sack_misordered):
            if tsn == tsn_plus_one(self._last_received_tsn):
                self._last_received_tsn = tsn
            else:
                break

        # filter out obsolete entries
        def is_obsolete(x):
            return uint32_gt(x, self._last_received_tsn)
        self._sack_duplicates = list(filter(is_obsolete, self._sack_duplicates))
        self._sack_misordered = set(filter(is_obsolete, self._sack_misordered))
534092
def MergeMessage(
      self, source, destination,
      replace_message, replace_repeated):
    """"""
    _MergeMessage(
        self._root, source, destination, replace_message, replace_repeated)
619822
def merge(self, other):
        
        Stats.merge(self, other)
        self.changes += other.changes
643301
def start_txn(self, txn_name=None):

		'''
		
		'''

		# if no name provided, create one
		if not txn_name:
			txn_name = uuid.uuid4().hex

		# request new transaction
		txn_response = self.api.http_request('POST','%s/fcr:tx' % self.root, data=None, headers=None)

		# if 201, transaction was created
		if txn_response.status_code == 201:

			txn_uri = txn_response.headers['Location']
			logger.debug("spawning transaction: %s" % txn_uri)

			# init new Transaction, and pass Expires header
			txn = Transaction(
				self, # pass the repository
				txn_name,
				txn_uri,
				expires = txn_response.headers['Expires'])

			# append to self
			self.txns[txn_name] = txn

			# return
			return txn
852464
def update(self, new_vals):
        
        for k, v in six.iteritems(new_vals):
            k = k.strip()
            if k in self.row:
                warnings.warn("Adding history key ({}) that is already set in this step".format(
                    k), wandb.WandbWarning)
            self.row[k] = v
609901
def update(self, identifier, new_instance):
        
        with self.flushing():
            instance = self.retrieve(identifier)
            self.merge(instance, new_instance)
            instance.updated_at = instance.new_timestamp()
        return instance
637541
def ProcessNewBlock(self, block):
        
        added = set()
        changed = set()
        deleted = set()

        try:
            # go through the list of transactions in the block and enumerate
            # over their outputs
            for tx in block.FullTransactions:

                for index, output in enumerate(tx.outputs):

                    # check to see if the outputs in the tx are in this wallet
                    state = self.CheckAddressState(output.ScriptHash)

                    if state & AddressState.InWallet > 0:

                        # if it's in the wallet, check to see if the coin exists yet
                        key = CoinReference(tx.Hash, index)

                        # if it exists, update it, otherwise create a new one
                        if key in self._coins.keys():
                            coin = self._coins[key]
                            coin.State |= CoinState.Confirmed
                            changed.add(coin)
                        else:
                            newcoin = Coin.CoinFromRef(coin_ref=key, tx_output=output, state=CoinState.Confirmed, transaction=tx)
                            self._coins[key] = newcoin
                            added.add(newcoin)

                        if state & AddressState.WatchOnly > 0:
                            self._coins[key].State |= CoinState.WatchOnly
                            changed.add(self._coins[key])

            # now iterate over the inputs of the tx and do the same
            for tx in block.FullTransactions:

                for input in tx.inputs:

                    if input in self._coins.keys():
                        if self._coins[input].Output.AssetId == Blockchain.SystemShare().Hash:
                            coin = self._coins[input]
                            coin.State |= CoinState.Spent | CoinState.Confirmed
                            changed.add(coin)

                        else:
                            deleted.add(self._coins[input])
                            del self._coins[input]

            for claimTx in [tx for tx in block.Transactions if tx.Type == TransactionType.ClaimTransaction]:

                for ref in claimTx.Claims:
                    if ref in self._coins.keys():
                        deleted.add(self._coins[ref])
                        del self._coins[ref]

            # update the current height of the wallet
            self._current_height += 1

            # in the case that another wallet implementation needs to do something
            # with the coins that have been changed ( ie persist to db ) this
            # method is called
            self.OnProcessNewBlock(block, added, changed, deleted)

            # this is not necessary at the moment, but any outside process
            # that wants to subscribe to the balance changed event could do
            # so from the BalanceChanged method
            if len(added) + len(deleted) + len(changed) > 0:
                self.BalanceChanged()

        except Exception as e:
            traceback.print_stack()
            traceback.print_exc()
            logger.error("could not process %s " % e)
1350336
def merge(*ds):
    
    if not ds:
        raise ValueError("Must provide at least one dict to merge().")
    out = {}
    for d in ds:
        out.update(d)
    return out
1176570
def MergeFrom(self, other):
    
    self._values.extend(other._values)
    self._message_listener.Modified()
997571
def _merge_results(self):
		
		new_dict = {}
		for it in self.data:
			new_dict.update(it)

		for k,v in new_dict.items():
			for kk, vv in v.time_stamps.items():
				for kkk,vvv in vv.items():
					new_dict[k].time_stamps[kk][kkk] = vvv - self.HB_config['time_ref']

		self.data = new_dict