Fix errors in block audit tx selection algorithm
This commit is contained in:
		
							parent
							
								
									702ff2796a
								
							
						
					
					
						commit
						39afa4cda1
					
				@ -207,10 +207,10 @@ class MempoolBlocks {
 | 
			
		||||
        if (nextTxSet && blockWeight + nextTxSet.weight < config.MEMPOOL.BLOCK_WEIGHT_UNITS) {
 | 
			
		||||
          blockWeight += nextTxSet.weight;
 | 
			
		||||
          // sort txSet by dependency graph (equivalent to sorting by ascending ancestor count)
 | 
			
		||||
          const sortedTxSet = nextTx.ancestors.sort((a, b) => {
 | 
			
		||||
          const sortedTxSet = [...nextTx.ancestors.sort((a, b) => {
 | 
			
		||||
            return (mempool[a.txid]?.ancestors?.length || 0) - (mempool[b.txid]?.ancestors?.length || 0);
 | 
			
		||||
          });
 | 
			
		||||
          [...sortedTxSet, nextTx].forEach((ancestor, i, arr) => {
 | 
			
		||||
          }), nextTx];
 | 
			
		||||
          sortedTxSet.forEach((ancestor, i, arr) => {
 | 
			
		||||
            const tx = mempool[ancestor.txid];
 | 
			
		||||
            const txSet = txSets[ancestor.txid];
 | 
			
		||||
            if (txSet.available) {
 | 
			
		||||
@ -340,7 +340,7 @@ class MempoolBlocks {
 | 
			
		||||
    if (txSet.children) {
 | 
			
		||||
      txSet.children.forEach(childId => {
 | 
			
		||||
        const child = mempool[childId];
 | 
			
		||||
        if (child && child.ancestors && txSets[childId]?.available) {
 | 
			
		||||
        if (child && child.ancestors) {
 | 
			
		||||
          const ancestorIndex = child.ancestors.findIndex(a => a.txid === root.txid);
 | 
			
		||||
          if (ancestorIndex > -1) {
 | 
			
		||||
            // remove tx as ancestor
 | 
			
		||||
@ -355,11 +355,12 @@ class MempoolBlocks {
 | 
			
		||||
              childTxSet.modified = true;
 | 
			
		||||
              modified.push(child);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // recursively update grandchildren
 | 
			
		||||
            anyModified = this.updateDescendants(root, child, mempool, txSets, modified) || anyModified;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        // recursively update grandchildren
 | 
			
		||||
        if (child) {
 | 
			
		||||
          anyModified = this.updateDescendants(root, child, mempool, txSets, modified) || anyModified;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
    return anyModified;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user