Commit e95b245b authored by metacertain's avatar metacertain Committed by GitHub

fix: increase minimum accepted threshold (#2098)

parent 08442482
......@@ -476,6 +476,9 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
<-syncedChan
}
minThreshold := big.NewInt(2 * refreshRate)
paymentThreshold, ok := new(big.Int).SetString(o.PaymentThreshold, 10)
if !ok {
return nil, fmt.Errorf("invalid payment threshold: %s", paymentThreshold)
......@@ -483,7 +486,9 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
pricer := pricer.NewFixedPricer(swarmAddress, basePrice)
minThreshold := pricer.MostExpensive()
if paymentThreshold.Cmp(minThreshold) < 0 {
return nil, fmt.Errorf("payment threshold below minimum generally accepted value, need at least %s", minThreshold)
}
pricing := pricing.New(p2ps, logger, paymentThreshold, minThreshold)
......
......@@ -5,8 +5,6 @@
package pricer
import (
"math/big"
"github.com/ethersphere/bee/pkg/swarm"
)
......@@ -41,10 +39,3 @@ func (pricer *FixedPricer) PeerPrice(peer, chunk swarm.Address) uint64 {
func (pricer *FixedPricer) Price(chunk swarm.Address) uint64 {
return pricer.PeerPrice(pricer.overlay, chunk)
}
func (pricer *FixedPricer) MostExpensive() *big.Int {
poPrice := new(big.Int).SetUint64(pricer.poPrice)
maxPO := new(big.Int).SetUint64(uint64(swarm.MaxPO))
tenTimesMaxPO := new(big.Int).Mul(big.NewInt(10), maxPO)
return new(big.Int).Mul(tenTimesMaxPO, poPrice)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment