|
15 | 15 | import knownnodes |
16 | 16 | import protocol |
17 | 17 | import state |
| 18 | +import dandelion |
18 | 19 | import connectionpool |
19 | 20 | from bmconfigparser import config |
20 | 21 | from queues import invQueue, objectProcessorQueue, portCheckerQueue |
@@ -337,27 +338,27 @@ def bm_command_getdata(self): |
337 | 338 | self.pendingUpload[str(i)] = now |
338 | 339 | return True |
339 | 340 |
|
340 | | - def _command_inv(self, dandelion=False): |
| 341 | + def _command_inv(self, extend_dandelion_stem=False): |
341 | 342 | """ |
342 | 343 | Common inv announce implementation: |
343 | | - both inv and dinv depending on *dandelion* kwarg |
| 344 | + both inv and dinv depending on *extend_dandelion_stem* kwarg |
344 | 345 | """ |
345 | 346 | items = self.decode_payload_content("l32s") |
346 | 347 |
|
347 | 348 | if len(items) > protocol.MAX_OBJECT_COUNT: |
348 | 349 | logger.error( |
349 | | - 'Too many items in %sinv message!', 'd' if dandelion else '') |
| 350 | + 'Too many items in %sinv message!', 'd' if extend_dandelion_stem else '') |
350 | 351 | raise BMProtoExcessiveDataError() |
351 | 352 |
|
352 | 353 | # ignore dinv if dandelion turned off |
353 | | - if dandelion and not state.dandelion_enabled: |
| 354 | + if extend_dandelion_stem and not state.dandelion_enabled: |
354 | 355 | return True |
355 | 356 |
|
356 | 357 | for i in map(str, items): |
357 | | - if i in state.Inventory and not state.Dandelion.hasHash(i): |
| 358 | + if i in state.Inventory and not dandelion.instance.hasHash(i): |
358 | 359 | continue |
359 | | - if dandelion and not state.Dandelion.hasHash(i): |
360 | | - state.Dandelion.addHash(i, self) |
| 360 | + if extend_dandelion_stem and not dandelion.instance.hasHash(i): |
| 361 | + dandelion.instance.addHash(i, self) |
361 | 362 | self.handleReceivedInventory(i) |
362 | 363 |
|
363 | 364 | return True |
@@ -419,9 +420,9 @@ def bm_command_object(self): |
419 | 420 | except KeyError: |
420 | 421 | pass |
421 | 422 |
|
422 | | - if self.object.inventoryHash in state.Inventory and state.Dandelion.hasHash( |
| 423 | + if self.object.inventoryHash in state.Inventory and dandelion.instance.hasHash( |
423 | 424 | self.object.inventoryHash): |
424 | | - state.Dandelion.removeHash( |
| 425 | + dandelion.instance.removeHash( |
425 | 426 | self.object.inventoryHash, "cycle detection") |
426 | 427 |
|
427 | 428 | state.Inventory[self.object.inventoryHash] = ( |
|
0 commit comments