-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from delta-mpc/zk
HLR Zk
- Loading branch information
Showing
108 changed files
with
7,578 additions
and
2,187 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
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 |
---|---|---|
@@ -1,47 +1,13 @@ | ||
import threading | ||
|
||
from delta_node import config | ||
from grpclib.client import Channel | ||
from grpclib.config import Configuration | ||
|
||
from .client import ChainClient | ||
|
||
__all__ = ["init", "get_client", "close"] | ||
|
||
_local = threading.local() | ||
|
||
|
||
def init( | ||
host: str = config.chain_host, port: int = config.chain_port, *, ssl: bool = False | ||
): | ||
if hasattr(_local, "ch") or hasattr(_local, "client"): | ||
raise ValueError("chain has been initialized") | ||
|
||
config = Configuration( | ||
_keepalive_time=10, | ||
_keepalive_timeout=5, | ||
_keepalive_permit_without_calls=True, | ||
_http2_max_pings_without_data=0, | ||
) | ||
ch = Channel(host, port, ssl=ssl, config=config) | ||
client = ChainClient(ch) | ||
_local.ch = ch | ||
_local.client = client | ||
|
||
|
||
def get_client() -> ChainClient: | ||
if not hasattr(_local, "client"): | ||
raise ValueError("chain has not been initialized") | ||
|
||
client: ChainClient = _local.client | ||
return client | ||
|
||
|
||
def close(): | ||
if (not hasattr(_local, "client")) or (not hasattr(_local, "ch")): | ||
raise ValueError("chain has not been initialized") | ||
|
||
ch: Channel = _local.ch | ||
ch.close() | ||
delattr(_local, "ch") | ||
delattr(_local, "client") | ||
from . import datahub, hlr, horizontal, identity, subscribe | ||
from .channel import close, get_channel, init | ||
|
||
__all__ = [ | ||
"init", | ||
"get_channel", | ||
"close", | ||
"datahub", | ||
"hlr", | ||
"horizontal", | ||
"identity", | ||
"subscribe", | ||
] |
Oops, something went wrong.