This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add partial support for admin_peers JSON-RPC API
- Loading branch information
Showing
9 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implement ``admin_peers`` JSON-RPC API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Sequence, Any | ||
|
||
from p2p.abc import SessionAPI | ||
|
||
try: | ||
import factory | ||
except ImportError: | ||
raise ImportError( | ||
"The p2p.tools.factories module requires the `factory_boy` and `faker` libraries." | ||
) | ||
|
||
|
||
from trinity.protocol.common.events import GetConnectedPeersResponse, PeerInfo | ||
|
||
|
||
class GetConnectedPeersResponseFactory(factory.Factory): | ||
class Meta: | ||
model = GetConnectedPeersResponse | ||
|
||
@classmethod | ||
def from_sessions(cls, | ||
sessions: Sequence[SessionAPI], | ||
*args: Any, | ||
**kwargs: Any) -> GetConnectedPeersResponse: | ||
return GetConnectedPeersResponse(tuple( | ||
PeerInfo( | ||
session=session, | ||
capabilities=(), | ||
client_version_string='unknown', | ||
inbound=False | ||
) for session in sessions | ||
)) |