Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
95cb1a00
Unverified
Commit
95cb1a00
authored
Nov 13, 2020
by
Steven Allen
Committed by
GitHub
Nov 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #447 from ipfs/fix/panic-and-leak
fix: set the score ledger on start
parents
b4720fab
ed0f4edf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
internal/decision/engine.go
internal/decision/engine.go
+4
-3
internal/decision/scoreledger.go
internal/decision/scoreledger.go
+0
-3
No files found.
internal/decision/engine.go
View file @
95cb1a00
...
...
@@ -178,6 +178,10 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger,
func
newEngine
(
ctx
context
.
Context
,
bs
bstore
.
Blockstore
,
peerTagger
PeerTagger
,
self
peer
.
ID
,
maxReplaceSize
int
,
scoreLedger
ScoreLedger
)
*
Engine
{
if
scoreLedger
==
nil
{
scoreLedger
=
NewDefaultScoreLedger
()
}
e
:=
&
Engine
{
ledgerMap
:
make
(
map
[
peer
.
ID
]
*
ledger
),
scoreLedger
:
scoreLedger
,
...
...
@@ -221,9 +225,6 @@ func (e *Engine) UseScoreLedger(scoreLedger ScoreLedger) {
// if it is unset, initializes the scoreLedger with the default
// implementation.
func
(
e
*
Engine
)
startScoreLedger
(
px
process
.
Process
)
{
if
e
.
scoreLedger
==
nil
{
e
.
scoreLedger
=
NewDefaultScoreLedger
()
}
e
.
scoreLedger
.
Start
(
func
(
p
peer
.
ID
,
score
int
)
{
if
score
==
0
{
e
.
peerTagger
.
UntagPeer
(
p
,
e
.
tagUseful
)
...
...
internal/decision/scoreledger.go
View file @
95cb1a00
...
...
@@ -102,8 +102,6 @@ func (l *scoreledger) Receipt() *Receipt {
// DefaultScoreLedger is used by Engine as the default ScoreLedger.
type
DefaultScoreLedger
struct
{
// a sample counting ticker
ticker
*
time
.
Ticker
// the score func
scorePeer
ScorePeerFunc
// is closed on Close
...
...
@@ -333,7 +331,6 @@ func (dsl *DefaultScoreLedger) PeerDisconnected(p peer.ID) {
func
NewDefaultScoreLedger
()
*
DefaultScoreLedger
{
return
&
DefaultScoreLedger
{
ledgerMap
:
make
(
map
[
peer
.
ID
]
*
scoreledger
),
ticker
:
time
.
NewTicker
(
time
.
Millisecond
*
100
),
closing
:
make
(
chan
struct
{}),
peerSampleInterval
:
shortTerm
,
}
...
...
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