Skip to content

Commit

Permalink
Update requirements.txt (aioipfs)
Browse files Browse the repository at this point in the history
Do many attempts when loading DIDs from the graph
  • Loading branch information
cipres authored and cipres committed Sep 3, 2020
1 parent fb91cca commit 08abed8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
34 changes: 24 additions & 10 deletions galacteek/core/ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def __init__(self, ctx):
self.evStopWatcher = asyncio.Event()
self._byPeerId = collections.OrderedDict()
self._byHandle = collections.OrderedDict()
self._didGraphLoadAtt = {}
self._pgScanCount = 0

self.peerAuthenticated.connectTo(self.onPeerAuthenticated)
Expand Down Expand Up @@ -321,8 +322,11 @@ async def scanNetworkGraph(self, ipfsop):
log.debug(f'DID {did}: already in model')
continue

ensure(self.loadDidFromGraph(
ipfsop, peerId, did, sHandle))
if did not in self._didGraphLoadAtt:
self._didGraphLoadAtt[did] = ensure(
self.loadDidFromGraph(
ipfsop, peerId, did, sHandle))

await ipfsop.sleep(0.1)

await ipfsop.sleep()
Expand All @@ -331,16 +335,24 @@ async def scanNetworkGraph(self, ipfsop):

async def loadDidFromGraph(self, ipfsop, peerId: str, did: str,
sHandle: str):
ipid = await self.app.ipidManager.load(
did,
track=True,
timeout=10,
localIdentifier=(peerId == ipfsop.ctx.node.id)
)
for attempt in range(0, 8):
ipid = await self.app.ipidManager.load(
did,
track=True,
timeout=10,
localIdentifier=(peerId == ipfsop.ctx.node.id)
)

if not ipid:
log.debug(f'Cannot load IPID: {did}, attempt {attempt}')
await ipfsop.sleep(60)
continue
else:
break

if not ipid:
log.debug(f'Cannot load IPID: {did}')
return
log.debug(f'Cannot load IPID: {did}, bailing out')
return False

piCtx = PeerIdentityCtx(
self.ctx,
Expand Down Expand Up @@ -368,6 +380,8 @@ async def loadDidFromGraph(self, ipfsop, peerId: str, did: str,

log.debug(f'Loaded IPID from graph: {did}')

return True

@ipfsOp
async def registerFromIdent(self, ipfsop, iMsg):
profile = ipfsop.ctx.currentProfile
Expand Down
27 changes: 15 additions & 12 deletions galacteek/ui/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,24 @@ def updatePinStatus(self, path, status, progress):
if not idx:
return

itemPath = self.model.itemFromIndex(idx)
if itemPath and time.time() - itemPath.lastProgressUpdate < 5:
return
try:
itemPath = self.model.itemFromIndex(idx)
if itemPath and time.time() - itemPath.lastProgressUpdate < 5:
return

itemProgress = self.model.itemFromIndex(
self.model.index(idx.row(), self.COL_PROGRESS, idx.parent())
)
itemProgress = self.model.itemFromIndex(
self.model.index(idx.row(), self.COL_PROGRESS, idx.parent())
)

itemStatus = self.model.itemFromIndex(
self.model.index(idx.row(), self.COL_STATUS, idx.parent())
)
itemStatus = self.model.itemFromIndex(
self.model.index(idx.row(), self.COL_STATUS, idx.parent())
)

itemStatus.setText(status)
itemProgress.setText(progress)
itemPath.lastProgressUpdate = time.time()
itemStatus.setText(status)
itemProgress.setText(progress)
itemPath.lastProgressUpdate = time.time()
except:
pass

def onPinFinished(self, path):
items = self.findPinItems(path)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aiodns>=2.0.0
aiofiles>=0.4.0
aiohttp>=3.4.4
aioipfs>=0.4.9
aioipfs>=0.4.10
aiojobs>=0.2.2
aiopubsub>=2.1.5
aiorwlock>=0.6.0
Expand Down

0 comments on commit 08abed8

Please sign in to comment.