[NOD-809] Change fee rate to fee per megagram (#730)

This commit is contained in:
Ori Newman 2020-05-24 16:59:37 +03:00 committed by GitHub
parent 6463a4b5d0
commit 96052ac69a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -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),
}

View File

@ -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

View File

@ -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)
}

View File

@ -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
}