2019-09-25 08:19:22 +08:00
|
|
|
from collections import OrderedDict
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
2019-10-28 17:48:00 +08:00
|
|
|
from libp2p.host.host_interface import IHost
|
2019-11-07 06:55:17 +08:00
|
|
|
from libp2p.host.ping import ID as PingID
|
|
|
|
from libp2p.host.ping import handle_ping
|
|
|
|
from libp2p.identity.identify.protocol import ID as IdentifyID
|
|
|
|
from libp2p.identity.identify.protocol import identify_handler_for
|
2019-10-28 17:48:00 +08:00
|
|
|
|
2019-09-25 08:19:22 +08:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from libp2p.typing import TProtocol, StreamHandlerFn
|
|
|
|
|
2019-10-24 16:27:15 +08:00
|
|
|
|
2019-10-28 17:48:00 +08:00
|
|
|
def get_default_protocols(host: IHost) -> "OrderedDict[TProtocol, StreamHandlerFn]":
|
2019-11-07 06:55:17 +08:00
|
|
|
return OrderedDict(
|
|
|
|
((IdentifyID, identify_handler_for(host)), (PingID, handle_ping))
|
|
|
|
)
|