import trio
from py_ipfs_lite.config import Config
from libp2p.peer.persistent.datastore.sqlite_sync import SQLiteDatastoreSync
from libp2p.peer.persistent.sync.peerstore import SyncPersistentPeerStore

def main():
    db_path = ".py_ipfs_lite/peerstore.db"
    datastore = SQLiteDatastoreSync(path=db_path)
    peerstore = SyncPersistentPeerStore(datastore=datastore)
    
    all_peers = peerstore.peer_ids()
    print(f"Total peers in DB: {len(all_peers)}")
    
    candidates = []
    for peer_id in all_peers:
        try:
            addrs = peerstore.addrs(peer_id)
            if addrs:
                candidates.append(peer_id)
        except Exception as e:
            pass
            
    print(f"Total candidates with addrs: {len(candidates)}")

main()
