1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 09:58:59 +01:00

Check minDatabase in background

This commit is contained in:
Alexander Pankratov 2021-02-27 23:00:03 +03:00
parent 7fe10430be
commit 0de5021afd

View File

@ -20,6 +20,7 @@
namespace danog\MadelineProto\MTProtoTools;
use Amp\Promise;
use danog\Loop\Loop;
use danog\MadelineProto\Db\DbArray;
use danog\MadelineProto\Db\DbPropertiesTrait;
use danog\MadelineProto\MTProto;
@ -88,13 +89,16 @@ class MinDatabase implements TLCallback
$this->clean = true;
return;
}
$iterator = $this->db->getIterator();
while (yield $iterator->advance()) {
[$id, $origin] = $iterator->getCurrent();
if (!isset($origin['peer']) || $origin['peer'] === $id) {
$this->db->offsetUnset($id);
\Amp\Loop::defer(function() {
$iterator = $this->db->getIterator();
while (yield $iterator->advance()) {
[$id, $origin] = $iterator->getCurrent();
if (!isset($origin['peer']) || $origin['peer'] === $id) {
$this->db->offsetUnset($id);
}
}
}
});
}
public function getMethodCallbacks(): array
{