Fix effective fee rates for non-cpfp dependents
This commit is contained in:
		
							parent
							
								
									126a75ed45
								
							
						
					
					
						commit
						70fa78b987
					
				@ -127,7 +127,7 @@ function makeBlockTemplates(mempool: Map<number, CompactThreadTransaction>)
 | 
			
		||||
          cpfpClusters.set(nextTx.uid, sortedTxSet.map(tx => tx.uid));
 | 
			
		||||
          isCluster = true;
 | 
			
		||||
        }
 | 
			
		||||
        const effectiveFeeRate = nextTx.ancestorFee / (nextTx.ancestorWeight / 4);
 | 
			
		||||
        const effectiveFeeRate = Math.min(nextTx.dependencyRate || Infinity, nextTx.ancestorFee / (nextTx.ancestorWeight / 4));
 | 
			
		||||
        const used: AuditTransaction[] = [];
 | 
			
		||||
        while (sortedTxSet.length) {
 | 
			
		||||
          const ancestor = sortedTxSet.pop();
 | 
			
		||||
@ -155,7 +155,7 @@ function makeBlockTemplates(mempool: Map<number, CompactThreadTransaction>)
 | 
			
		||||
        // remove these as valid package ancestors for any descendants remaining in the mempool
 | 
			
		||||
        if (used.length) {
 | 
			
		||||
          used.forEach(tx => {
 | 
			
		||||
            updateDescendants(tx, auditPool, modified);
 | 
			
		||||
            updateDescendants(tx, auditPool, modified, effectiveFeeRate);
 | 
			
		||||
          });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -251,6 +251,7 @@ function updateDescendants(
 | 
			
		||||
  rootTx: AuditTransaction,
 | 
			
		||||
  mempool: Map<number, AuditTransaction>,
 | 
			
		||||
  modified: PairingHeap<AuditTransaction>,
 | 
			
		||||
  clusterRate: number,
 | 
			
		||||
): void {
 | 
			
		||||
  const descendantSet: Set<AuditTransaction> = new Set();
 | 
			
		||||
  // stack of nodes left to visit
 | 
			
		||||
@ -272,6 +273,7 @@ function updateDescendants(
 | 
			
		||||
      descendantTx.ancestorWeight -= rootTx.weight;
 | 
			
		||||
      tmpScore = descendantTx.score;
 | 
			
		||||
      descendantTx.score = descendantTx.ancestorFee / (descendantTx.ancestorWeight / 4);
 | 
			
		||||
      descendantTx.dependencyRate = descendantTx.dependencyRate ? Math.min(descendantTx.dependencyRate, clusterRate) : clusterRate;
 | 
			
		||||
 | 
			
		||||
      if (!descendantTx.modifiedNode) {
 | 
			
		||||
        descendantTx.modified = true;
 | 
			
		||||
 | 
			
		||||
@ -104,6 +104,7 @@ export interface AuditTransaction {
 | 
			
		||||
  used: boolean;
 | 
			
		||||
  modified: boolean;
 | 
			
		||||
  modifiedNode: HeapNode<AuditTransaction>;
 | 
			
		||||
  dependencyRate?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface CompactThreadTransaction {
 | 
			
		||||
 | 
			
		||||
@ -481,7 +481,7 @@
 | 
			
		||||
          </ng-template>
 | 
			
		||||
        </td>
 | 
			
		||||
      </tr>
 | 
			
		||||
      <tr *ngIf="cpfpInfo && (cpfpInfo?.bestDescendant || cpfpInfo?.descendants?.length || cpfpInfo?.ancestors?.length)">
 | 
			
		||||
      <tr *ngIf="cpfpInfo && (cpfpInfo.effectiveFeePerVsize || cpfpInfo.bestDescendant || cpfpInfo.descendants?.length || cpfpInfo.ancestors?.length)">
 | 
			
		||||
        <td i18n="transaction.effective-fee-rate|Effective transaction fee rate">Effective fee rate</td>
 | 
			
		||||
        <td>
 | 
			
		||||
          <div class="effective-fee-container">
 | 
			
		||||
@ -490,7 +490,7 @@
 | 
			
		||||
              <app-tx-fee-rating class="ml-2 mr-2" *ngIf="tx.fee || tx.effectiveFeePerVsize" [tx]="tx"></app-tx-fee-rating>
 | 
			
		||||
            </ng-template>
 | 
			
		||||
          </div>
 | 
			
		||||
          <button type="button" class="btn btn-outline-info btn-sm btn-small-height float-right" (click)="showCpfpDetails = !showCpfpDetails">CPFP <fa-icon [icon]="['fas', 'info-circle']" [fixedWidth]="true"></fa-icon></button>
 | 
			
		||||
          <button *ngIf="cpfpInfo.bestDescendant || cpfpInfo.descendants?.length || cpfpInfo.ancestors?.length" type="button" class="btn btn-outline-info btn-sm btn-small-height float-right" (click)="showCpfpDetails = !showCpfpDetails">CPFP <fa-icon [icon]="['fas', 'info-circle']" [fixedWidth]="true"></fa-icon></button>
 | 
			
		||||
        </td>
 | 
			
		||||
      </tr>
 | 
			
		||||
    </tbody>
 | 
			
		||||
 | 
			
		||||
@ -164,14 +164,17 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
 | 
			
		||||
        if (cpfpInfo.bestDescendant && !cpfpInfo.descendants?.length) {
 | 
			
		||||
          relatives.push(cpfpInfo.bestDescendant);
 | 
			
		||||
        }
 | 
			
		||||
        let totalWeight =
 | 
			
		||||
          this.tx.weight +
 | 
			
		||||
          relatives.reduce((prev, val) => prev + val.weight, 0);
 | 
			
		||||
        let totalFees =
 | 
			
		||||
          this.tx.fee +
 | 
			
		||||
          relatives.reduce((prev, val) => prev + val.fee, 0);
 | 
			
		||||
 | 
			
		||||
        this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4);
 | 
			
		||||
        if (!cpfpInfo.effectiveFeePerVsize) {
 | 
			
		||||
          let totalWeight =
 | 
			
		||||
            this.tx.weight +
 | 
			
		||||
            relatives.reduce((prev, val) => prev + val.weight, 0);
 | 
			
		||||
          let totalFees =
 | 
			
		||||
            this.tx.fee +
 | 
			
		||||
            relatives.reduce((prev, val) => prev + val.fee, 0);
 | 
			
		||||
          this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4);
 | 
			
		||||
        } else {
 | 
			
		||||
          this.tx.effectiveFeePerVsize = cpfpInfo.effectiveFeePerVsize;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.cpfpInfo = cpfpInfo;
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,7 @@ export interface CpfpInfo {
 | 
			
		||||
  ancestors: Ancestor[];
 | 
			
		||||
  descendants?: Ancestor[];
 | 
			
		||||
  bestDescendant?: BestDescendant | null;
 | 
			
		||||
  effectiveFeePerVsize?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface RbfInfo {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user