Updates for untyped btcutil consts.

This commit is contained in:
Josh Rickmar 2014-07-08 11:22:09 -05:00
parent 9036d36e68
commit 0abe6e32bf
3 changed files with 11 additions and 11 deletions

View file

@ -370,20 +370,20 @@ func minimumFee(tx *btcwire.MsgTx, allowFree bool) btcutil.Amount {
}
}
max := btcutil.Amount(btcutil.MaxSatoshi)
if fee < 0 || fee > max {
fee = max
if fee < 0 || fee > btcutil.MaxSatoshi {
fee = btcutil.MaxSatoshi
}
return fee
}
// allowFree calculates the transaction priority and checks that the
// priority reaches a certain threshhold. If the threshhold is
// priority reaches a certain threshold. If the threshhold is
// reached, a free transaction fee is allowed.
func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool {
const blocksPerDayEstimate = 144
const txSizeEstimate = 250
const blocksPerDayEstimate = 144.0
const txSizeEstimate = 250.0
const threshold = btcutil.SatoshiPerBitcoin * blocksPerDayEstimate / txSizeEstimate
var weightedSum int64
for _, txout := range txouts {
@ -391,7 +391,7 @@ func allowFree(curHeight int32, txouts []txstore.Credit, txSize int) bool {
weightedSum += int64(txout.Amount()) * int64(depth)
}
priority := float64(weightedSum) / float64(txSize)
return priority > float64(btcutil.SatoshiPerBitcoin)*blocksPerDayEstimate/txSizeEstimate
return priority > threshold
}
// chainDepth returns the chaindepth of a target given the current

View file

@ -38,7 +38,7 @@ var allowFreeTests = []allowFreeTest{
name: "priority < 57,600,000",
inputs: []*tx.Utxo{
{
Amt: uint64(btcutil.SatoshiPerBitcoin),
Amt: btcutil.SatoshiPerBitcoin,
Height: 0,
},
},
@ -50,7 +50,7 @@ var allowFreeTests = []allowFreeTest{
name: "priority == 57,600,000",
inputs: []*tx.Utxo{
{
Amt: uint64(btcutil.SatoshiPerBitcoin),
Amt: btcutil.SatoshiPerBitcoin,
Height: 0,
},
},
@ -62,7 +62,7 @@ var allowFreeTests = []allowFreeTest{
name: "priority > 57,600,000",
inputs: []*tx.Utxo{
{
Amt: uint64(btcutil.SatoshiPerBitcoin),
Amt: btcutil.SatoshiPerBitcoin,
Height: 0,
},
},

View file

@ -1348,7 +1348,7 @@ func GetInfo(icmd btcjson.Cmd) (interface{}, error) {
info.KeypoolOldest = time.Now().Unix()
info.KeypoolSize = int32(cfg.KeypoolSize)
TxFeeIncrement.Lock()
info.PaytxFee = float64(TxFeeIncrement.i) / float64(btcutil.SatoshiPerBitcoin)
info.PaytxFee = float64(TxFeeIncrement.i) / btcutil.SatoshiPerBitcoin
TxFeeIncrement.Unlock()
// We don't set the following since they don't make much sense in the
// wallet architecture: