Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
75e9a0c9
Commit
75e9a0c9
authored
Mar 11, 2017
by
Lars Gierth
Browse files
WIP
parent
75ba71bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/p2p.go
0 → 100644
View file @
75e9a0c9
package
p2p
import
(
ma
"github.com/multiformats/go-multiaddr"
manet
"github.com/multiformats/go-multiaddr-net"
)
var
P2PProtocol
=
ma
.
Protocol
{
Code
:
420
,
Name
:
"p2p"
,
VCode
:
ma
.
CodeToVarint
(
420
),
}
var
IpfsProtocol
=
ma
.
Protocol
{
Code
:
421
,
Name
:
"ipfs"
,
VCode
:
ma
.
CodeToVarint
(
421
),
}
var
P2PCodec
=
&
manet
.
NetCodec
{
NetAddrNetworks
:
[]
string
{
"libp2p"
},
ProtocolName
:
"p2p"
,
ConvertMultiaddr
:
ConvertP2PMultiaddr
,
ParseNetAddr
:
ParseP2PNetAddr
,
}
var
IpfsCodec
=
&
manet
.
NetCodec
{
NetAddrNetworks
:
[]
string
{
"libp2p+ipfs"
},
ProtocolName
:
"ipfs"
,
ConvertMultiaddr
:
ConvertIpfsMultiaddr
,
ParseNetAddr
:
ParseIpfsNetAddr
,
}
func
init
()
{
err
:=
ma
.
AddProtocol
(
P2PProtocol
)
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"error registering libp2p protocol: %s"
,
err
))
}
err
=
ma
.
AddProtocol
(
IpfsProtocol
)
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"error registering libp2p+ipfs protocol: %s"
,
err
))
}
manet
.
RegisterNetCodec
(
P2PCodec
)
manet
.
RegisterNetCodec
(
IpfsCodec
)
}
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