mirror of
https://github.com/bitromortac/lndmanage.git
synced 2026-08-13 12:33:37 +02:00
Merge pull request #133 from 3nprob/fix-networkx-pickle-deprecation
network: fix networkx deprecated function usage
This commit is contained in:
commit
ebd6431efd
1 changed files with 4 additions and 2 deletions
|
|
@ -62,11 +62,13 @@ class Network:
|
|||
if timestamp_graph < time.time() - settings.CACHING_RETENTION_MINUTES * 60: # old graph in file
|
||||
logger.info(f"Cached graph is too old. Fetching new one.")
|
||||
self.set_graph_and_edges()
|
||||
nx.write_gpickle(self.graph, cache_graph_filename)
|
||||
with open(cache_graph_filename, 'wb') as file:
|
||||
pickle.dump(self.graph, file, pickle.HIGHEST_PROTOCOL)
|
||||
with open(cache_edges_filename, 'wb') as file:
|
||||
pickle.dump(self.edges, file)
|
||||
else: # recent graph in file
|
||||
self.graph = nx.read_gpickle(cache_graph_filename)
|
||||
with open(cache_graph_filename, 'rb') as file:
|
||||
self.graph = pickle.load(file)
|
||||
with open(cache_edges_filename, 'rb') as file:
|
||||
self.edges = pickle.load(file)
|
||||
logger.info(f"> Loaded graph from file: {len(self.graph)} nodes, {len(self.edges)} channels.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue