Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
neo
Commits
ae55336c
Commit
ae55336c
authored
May 11, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X errcontextf syntax sugar
parent
4b41deaa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
go/neo/server.go
go/neo/server.go
+20
-1
No files found.
go/neo/server.go
View file @
ae55336c
...
...
@@ -89,15 +89,31 @@ func ListenAndServe(ctx context.Context, net_, laddr string, srv Server) error {
// ----------------------------------------
// errcontextf adds formatted prefix context to *errp
// must be called under defer
func
errcontextf
(
errp
*
error
,
format
string
,
argv
...
interface
{})
{
if
*
errp
==
nil
{
return
}
format
+=
": %s"
argv
=
append
(
argv
,
*
errp
)
*
errp
=
fmt
.
Errorf
(
format
,
argv
...
)
}
// IdentifyPeer identifies peer on the link
// it expects peer to send RequestIdentification packet and replies with AcceptIdentification if identification passes.
// returns information about identified node or error.
func
IdentifyPeer
(
link
*
NodeLink
,
myNodeType
NodeType
)
(
nodeInfo
RequestIdentification
/*TODO -> NodeInfo*/
,
err
error
)
{
defer
errcontextf
(
&
err
,
"%s: identify"
,
link
)
/*
defer func() {
if err != nil {
err = fmt.Errorf("%s: identify: %s", link, err)
}
}()
*/
// the first conn must come with RequestIdentification packet
conn
,
err
:=
link
.
Accept
()
...
...
@@ -146,11 +162,15 @@ func IdentifyPeer(link *NodeLink, myNodeType NodeType) (nodeInfo RequestIdentifi
// IdentifyMe identifies local node to remote peer
func
IdentifyMe
(
link
*
NodeLink
,
nodeType
NodeType
/*XXX*/
)
(
peerType
NodeType
,
err
error
)
{
defer
errcontextf
(
&
err
,
"%s: request identification"
,
link
)
/*
defer func() {
if err != nil {
err = fmt.Errorf("%s: request identification: %s", link, err)
}
}()
*/
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
...
...
@@ -173,7 +193,6 @@ func IdentifyMe(link *NodeLink, nodeType NodeType /*XXX*/) (peerType NodeType, e
})
if
err
!=
nil
{
fmt
.
Printf
(
"eee -> %v
\n
"
,
err
)
return
peerType
,
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