Onionr/static-data/default-plugins/tor/shutdown.py

13 lines
349 B
Python
Raw Normal View History

2022-05-31 00:52:03 +00:00
import shelve
from gossip.peerset import gossip_peer_set
from torpeer import TorPeer
from torfilepaths import peer_database_file
def on_shutdown_event(api, data=None):
with shelve.open(peer_database_file, 'c') as db:
for peer in gossip_peer_set:
if isinstance(peer, TorPeer):
db[peer.onion_address] = peer