mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-809] Change fee rate to fee per megagram (#730)
This commit is contained in:
parent
6463a4b5d0
commit
96052ac69a
@ -668,12 +668,16 @@ func (mp *TxPool) RemoveDoubleSpends(tx *util.Tx) {
|
||||
func (mp *TxPool) addTransaction(tx *util.Tx, fee uint64, parentsInPool []*wire.Outpoint) (*TxDesc, error) {
|
||||
// Add the transaction to the pool and mark the referenced outpoints
|
||||
// as spent by the pool.
|
||||
mass, err := blockdag.CalcTxMassFromUTXOSet(tx, mp.mpUTXOSet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
txD := &TxDesc{
|
||||
TxDesc: mining.TxDesc{
|
||||
Tx: tx,
|
||||
Added: time.Now(),
|
||||
Fee: fee,
|
||||
FeePerKB: fee * 1000 / uint64(tx.MsgTx().SerializeSize()),
|
||||
Tx: tx,
|
||||
Added: time.Now(),
|
||||
Fee: fee,
|
||||
FeePerMegaGram: fee * 1e6 / mass,
|
||||
},
|
||||
depCount: len(parentsInPool),
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ type TxDesc struct {
|
||||
// Fee is the total fee the transaction associated with the entry pays.
|
||||
Fee uint64
|
||||
|
||||
// FeePerKB is the fee the transaction pays in sompi per 1000 bytes.
|
||||
FeePerKB uint64
|
||||
// FeePerMegaGram is the fee the transaction pays in sompi per million gram.
|
||||
FeePerMegaGram uint64
|
||||
}
|
||||
|
||||
// TxSource represents a source of transactions to consider for inclusion in
|
||||
|
@ -301,8 +301,8 @@ func (g *BlkTmplGenerator) populateTemplateFromCandidates(candidateTxs []*candid
|
||||
txsForBlockTemplate.totalMass += selectedTx.txMass
|
||||
txsForBlockTemplate.totalFees += selectedTx.txDesc.Fee
|
||||
|
||||
log.Tracef("Adding tx %s (feePerKB %d)",
|
||||
tx.ID(), selectedTx.txDesc.FeePerKB)
|
||||
log.Tracef("Adding tx %s (feePerMegaGram %d)",
|
||||
tx.ID(), selectedTx.txDesc.FeePerMegaGram)
|
||||
|
||||
markCandidateTxForDeletion(selectedTx)
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ func (s *Server) handleRelayInvMsg(state *peerState, msg relayMsg) {
|
||||
// Don't relay the transaction if the transaction fee-per-kb
|
||||
// is less than the peer's feefilter.
|
||||
feeFilter := uint64(atomic.LoadInt64(&sp.FeeFilterInt))
|
||||
if feeFilter > 0 && txD.FeePerKB < feeFilter {
|
||||
if feeFilter > 0 && txD.FeePerMegaGram < feeFilter {
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user