[ctr] Remove state db fee when payload is zero
@@ -8,12 +8,12 @@ const (
baseTxFee = "2000000000000000" // 0.002 AERGO
aerPerByte = 5000000000000 // 5,000 GAER, feePerBytes * PayloadMaxBytes = 1 AERGO
payloadMaxSize = 200 * 1024
- StateDbMaxUpdateSize = payloadMaxSize + FreeByteSize
- FreeByteSize = 200
+ StateDbMaxUpdateSize = payloadMaxSize
+ freeByteSize = 200
)
var (
- payloadTxFee *big.Int
+ baseTxAergo *big.Int
zeroFee bool
stateDbMaxFee *big.Int
zero *big.Int
@@ -21,10 +21,10 @@ var (
)
func init() {
- payloadTxFee, _ = new(big.Int).SetString(baseTxFee, 10)
+ baseTxAergo, _ = new(big.Int).SetString(baseTxFee, 10)
zeroFee = false
AerPerByte = big.NewInt(aerPerByte)
- stateDbMaxFee = new(big.Int).Mul(AerPerByte, big.NewInt(StateDbMaxUpdateSize - FreeByteSize))
+ stateDbMaxFee = new(big.Int).Mul(AerPerByte, big.NewInt(StateDbMaxUpdateSize-freeByteSize))
zero = big.NewInt(0)
}
@@ -45,7 +45,7 @@ func PayloadTxFee(payloadSize int) *big.Int {
size = payloadMaxSize
}
return new(big.Int).Add(
- payloadTxFee,
+ baseTxAergo,
new(big.Int).Mul(
AerPerByte,
big.NewInt(size),
@@ -57,11 +57,14 @@ func MaxPayloadTxFee(payloadSize int) *big.Int {
if IsZeroFee() {
return zero
}
+ if payloadSize == 0 {
+ return baseTxAergo
+ }
return new(big.Int).Add(PayloadTxFee(payloadSize), stateDbMaxFee)
}
func PaymentDataSize(dataSize int64) int64 {
- pSize := dataSize - FreeByteSize
+ pSize := dataSize - freeByteSize
if pSize < 0 {
pSize = 0
}
