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
mf
go-multiaddr
Commits
47e3ab13
Commit
47e3ab13
authored
Jun 22, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validate protocol definition in add protocol
parent
ece734f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
protocols.go
protocols.go
+6
-0
No files found.
protocols.go
View file @
47e3ab13
...
...
@@ -120,6 +120,12 @@ func SwapToP2pMultiaddrs() {
}
func
AddProtocol
(
p
Protocol
)
error
{
if
p
.
Size
!=
0
&&
p
.
Transcoder
==
nil
{
return
fmt
.
Errorf
(
"protocols with arguments must define transcoders"
)
}
if
p
.
Path
&&
p
.
Size
>=
0
{
return
fmt
.
Errorf
(
"path protocols must have variable-length sizes"
)
}
for
_
,
pt
:=
range
Protocols
{
if
pt
.
Code
==
p
.
Code
{
return
fmt
.
Errorf
(
"protocol code %d already taken by %q"
,
p
.
Code
,
pt
.
Name
)
...
...
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