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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user