Commit 22fcd712 authored by metacertain's avatar metacertain Committed by GitHub

fix: introduce max threshold (#2154)

parent fa40048c
...@@ -507,6 +507,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -507,6 +507,7 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
} }
minThreshold := big.NewInt(2 * refreshRate) minThreshold := big.NewInt(2 * refreshRate)
maxThreshold := big.NewInt(24 * refreshRate)
paymentThreshold, ok := new(big.Int).SetString(o.PaymentThreshold, 10) paymentThreshold, ok := new(big.Int).SetString(o.PaymentThreshold, 10)
if !ok { if !ok {
...@@ -519,6 +520,10 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo ...@@ -519,6 +520,10 @@ func NewBee(addr string, publicKey *ecdsa.PublicKey, signer crypto.Signer, netwo
return nil, fmt.Errorf("payment threshold below minimum generally accepted value, need at least %s", minThreshold) return nil, fmt.Errorf("payment threshold below minimum generally accepted value, need at least %s", minThreshold)
} }
if paymentThreshold.Cmp(maxThreshold) > 0 {
return nil, fmt.Errorf("payment threshold above maximum generally accepted value, needs to be reduced to at most %s", maxThreshold)
}
pricing := pricing.New(p2ps, logger, paymentThreshold, minThreshold) pricing := pricing.New(p2ps, logger, paymentThreshold, minThreshold)
if err = p2ps.AddProtocol(pricing.Protocol()); err != nil { if err = p2ps.AddProtocol(pricing.Protocol()); err != nil {
......
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