Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
06ce0488
Unverified
Commit
06ce0488
authored
Sep 14, 2020
by
Ralph Pichler
Committed by
GitHub
Sep 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block peers on disconnect threshold (#694)
parent
159efc59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
accounting.go
pkg/accounting/accounting.go
+2
-1
accounting_test.go
pkg/accounting/accounting_test.go
+3
-3
No files found.
pkg/accounting/accounting.go
View file @
06ce0488
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"fmt"
"fmt"
"strings"
"strings"
"sync"
"sync"
"time"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p"
...
@@ -253,7 +254,7 @@ func (a *Accounting) Debit(peer swarm.Address, price uint64) error {
...
@@ -253,7 +254,7 @@ func (a *Accounting) Debit(peer swarm.Address, price uint64) error {
if
nextBalance
>=
int64
(
a
.
paymentThreshold
+
a
.
paymentTolerance
)
{
if
nextBalance
>=
int64
(
a
.
paymentThreshold
+
a
.
paymentTolerance
)
{
// peer too much in debt
// peer too much in debt
a
.
metrics
.
AccountingDisconnectsCount
.
Inc
()
a
.
metrics
.
AccountingDisconnectsCount
.
Inc
()
return
p2p
.
New
DisconnectError
(
ErrDisconnectThresholdExceeded
)
return
p2p
.
New
BlockPeerError
(
10000
*
time
.
Hour
,
ErrDisconnectThresholdExceeded
)
}
}
return
nil
return
nil
...
...
pkg/accounting/accounting_test.go
View file @
06ce0488
...
@@ -197,7 +197,7 @@ func TestAccountingReserve(t *testing.T) {
...
@@ -197,7 +197,7 @@ func TestAccountingReserve(t *testing.T) {
}
}
}
}
// TestAccountingDisconnect tests that exceeding the disconnect threshold with Debit returns a p2p.
Disconnect
Error
// TestAccountingDisconnect tests that exceeding the disconnect threshold with Debit returns a p2p.
BlockPeer
Error
func
TestAccountingDisconnect
(
t
*
testing
.
T
)
{
func
TestAccountingDisconnect
(
t
*
testing
.
T
)
{
logger
:=
logging
.
New
(
ioutil
.
Discard
,
0
)
logger
:=
logging
.
New
(
ioutil
.
Discard
,
0
)
...
@@ -231,9 +231,9 @@ func TestAccountingDisconnect(t *testing.T) {
...
@@ -231,9 +231,9 @@ func TestAccountingDisconnect(t *testing.T) {
t
.
Fatal
(
"expected Add to return error"
)
t
.
Fatal
(
"expected Add to return error"
)
}
}
var
e
*
p2p
.
Disconnect
Error
var
e
*
p2p
.
BlockPeer
Error
if
!
errors
.
As
(
err
,
&
e
)
{
if
!
errors
.
As
(
err
,
&
e
)
{
t
.
Fatalf
(
"expected
Disconnect
Error, got %v"
,
err
)
t
.
Fatalf
(
"expected
BlockPeer
Error, got %v"
,
err
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment