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
f373ffbc
Commit
f373ffbc
authored
Jan 28, 2020
by
Petar Radovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move error from libp2p to p2p
parent
8e918782
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
error.go
pkg/p2p/error.go
+7
-7
libp2p.go
pkg/p2p/libp2p/libp2p.go
+1
-1
No files found.
pkg/p2p/
libp2p/
error.go
→
pkg/p2p/error.go
View file @
f373ffbc
...
...
@@ -2,26 +2,26 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
lib
p2p
package
p2p
//
This error is handled specially by lib
p2p. If returned by specific protocol
//
DisconnectError is an error that is specifically handled inside
p2p. If returned by specific protocol
// handler it causes peer disconnect.
type
d
isconnectError
struct
{
type
D
isconnectError
struct
{
err
error
}
// Disconnect wraps error and creates a special error that is treated specially
// by
lib
p2p. It causes peer to disconnect.
// by p2p. It causes peer to disconnect.
func
Disconnect
(
err
error
)
error
{
return
&
d
isconnectError
{
return
&
D
isconnectError
{
err
:
err
,
}
}
// Unwrap returns an underlying error.
func
(
e
*
d
isconnectError
)
Unwrap
()
error
{
return
e
.
err
}
func
(
e
*
D
isconnectError
)
Unwrap
()
error
{
return
e
.
err
}
// Error implements function of the standard go error interface.
func
(
e
*
d
isconnectError
)
Error
()
string
{
func
(
e
*
D
isconnectError
)
Error
()
string
{
return
e
.
err
.
Error
()
}
pkg/p2p/libp2p/libp2p.go
View file @
f373ffbc
...
...
@@ -268,7 +268,7 @@ func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) {
s
.
metrics
.
HandledStreamCount
.
Inc
()
if
err
:=
ss
.
Handler
(
p2p
.
Peer
{
Address
:
overlay
},
stream
);
err
!=
nil
{
var
e
*
d
isconnectError
var
e
*
p2p
.
D
isconnectError
if
errors
.
Is
(
err
,
e
)
{
// todo: test connection close and refactor
s
.
peers
.
remove
(
peerID
)
...
...
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