Fix accelerator revenue impact always showing zero

The old approach compared coinbasevalue from two getblocktemplate
calls, but new mempool arrivals between calls masked the displacement
loss. Now uses a single template snapshot to find the marginal
(lowest fee-rate) transaction that would be displaced and reports
its fee as the revenue cost.
This commit is contained in:
satoshi
2026-05-27 14:23:05 +03:00
parent 8242eec265
commit 83d70b2636
3 changed files with 73 additions and 29 deletions
+10 -2
View File
@@ -273,11 +273,19 @@ func (c *RPC) GetNetworkHashPS(ctx context.Context, blocks, height int) (float64
return out, nil
}
// TemplateTx is one transaction inside a getblocktemplate result.
type TemplateTx struct {
Txid string `json:"txid"`
Fee int64 `json:"fee"` // satoshis
Weight int64 `json:"weight"` // weight units
}
// BlockTemplate is the subset of getblocktemplate we care about: the
// coinbase value (subsidy + fees) and height of the next block.
type BlockTemplate struct {
CoinbaseValue int64 `json:"coinbasevalue"` // satoshis
Height int64 `json:"height"`
CoinbaseValue int64 `json:"coinbasevalue"` // satoshis
Height int64 `json:"height"`
Transactions []TemplateTx `json:"transactions"`
}
// GetBlockTemplate fetches the next block template with segwit rules.