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
2c8c0632
Unverified
Commit
2c8c0632
authored
Mar 27, 2021
by
Esad Akar
Committed by
GitHub
Mar 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pusher: receipt can only be nil for ErrWantSelf cases (#1494)
parent
a342f89c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
pusher.go
pkg/pusher/pusher.go
+17
-12
No files found.
pkg/pusher/pusher.go
View file @
2c8c0632
...
@@ -10,6 +10,7 @@ package pusher
...
@@ -10,6 +10,7 @@ package pusher
import
(
import
(
"context"
"context"
"crypto/ecdsa"
"errors"
"errors"
"fmt"
"fmt"
"sync"
"sync"
...
@@ -138,7 +139,7 @@ LOOP:
...
@@ -138,7 +139,7 @@ LOOP:
err
error
err
error
startTime
=
time
.
Now
()
startTime
=
time
.
Now
()
t
*
tags
.
Tag
t
*
tags
.
Tag
setSent
bool
wantSelf
bool
storerPeer
swarm
.
Address
storerPeer
swarm
.
Address
)
)
defer
func
()
{
defer
func
()
{
...
@@ -156,6 +157,7 @@ LOOP:
...
@@ -156,6 +157,7 @@ LOOP:
mtx
.
Unlock
()
mtx
.
Unlock
()
<-
sem
<-
sem
}()
}()
// Later when we process receipt, get the receipt and process it
// Later when we process receipt, get the receipt and process it
// for now ignoring the receipt and checking only for error
// for now ignoring the receipt and checking only for error
receipt
,
err
:=
s
.
pushSyncer
.
PushChunkToClosest
(
ctx
,
ch
)
receipt
,
err
:=
s
.
pushSyncer
.
PushChunkToClosest
(
ctx
,
ch
)
...
@@ -165,22 +167,25 @@ LOOP:
...
@@ -165,22 +167,25 @@ LOOP:
// this is to make sure that the sent number does not diverge from the synced counter
// this is to make sure that the sent number does not diverge from the synced counter
// the edge case is on the uploader node, in the case where the uploader node is
// the edge case is on the uploader node, in the case where the uploader node is
// connected to other nodes, but is the closest one to the chunk.
// connected to other nodes, but is the closest one to the chunk.
setSent
=
true
wantSelf
=
true
}
else
{
}
else
{
return
return
}
}
}
}
publicKey
,
err
:=
crypto
.
Recover
(
receipt
.
Signature
,
receipt
.
Address
.
Bytes
())
if
receipt
!=
nil
{
if
err
!=
nil
{
var
publicKey
*
ecdsa
.
PublicKey
err
=
fmt
.
Errorf
(
"pusher: receipt recover: %w"
,
err
)
publicKey
,
err
=
crypto
.
Recover
(
receipt
.
Signature
,
receipt
.
Address
.
Bytes
())
return
if
err
!=
nil
{
}
err
=
fmt
.
Errorf
(
"pusher: receipt recover: %w"
,
err
)
return
}
storerPeer
,
err
=
crypto
.
NewOverlayAddress
(
*
publicKey
,
s
.
networkID
)
storerPeer
,
err
=
crypto
.
NewOverlayAddress
(
*
publicKey
,
s
.
networkID
)
if
err
!=
nil
{
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"pusher: receipt storer address: %w"
,
err
)
err
=
fmt
.
Errorf
(
"pusher: receipt storer address: %w"
,
err
)
return
return
}
}
}
if
err
=
s
.
storer
.
Set
(
ctx
,
storage
.
ModeSetSync
,
ch
.
Address
());
err
!=
nil
{
if
err
=
s
.
storer
.
Set
(
ctx
,
storage
.
ModeSetSync
,
ch
.
Address
());
err
!=
nil
{
...
@@ -195,7 +200,7 @@ LOOP:
...
@@ -195,7 +200,7 @@ LOOP:
err
=
fmt
.
Errorf
(
"pusher: increment synced: %v"
,
err
)
err
=
fmt
.
Errorf
(
"pusher: increment synced: %v"
,
err
)
return
return
}
}
if
setSent
{
if
wantSelf
{
err
=
t
.
Inc
(
tags
.
StateSent
)
err
=
t
.
Inc
(
tags
.
StateSent
)
if
err
!=
nil
{
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"pusher: increment sent: %w"
,
err
)
err
=
fmt
.
Errorf
(
"pusher: increment sent: %w"
,
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