Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner committed Aug 20, 2024
1 parent a1aac1c commit b21e04e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Services/BeamService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function createPackClaims(Model $beam, array $packs, bool $isNew = false)
$quantity++;
}

$model = BeamPack::firstOrcreate(['id' => $id], [
$beamPack = BeamPack::firstOrcreate(['id' => $id], [
'beam_id' => $beam->id,
'code' => bin2hex(openssl_random_pseudo_bytes(16)),
'nonce' => 1,
Expand All @@ -134,13 +134,13 @@ public function createPackClaims(Model $beam, array $packs, bool $isNew = false)

if ($tokenIds->count()) {
$allTokenIds = $tokenIds->pluck('tokenIds')->flatten()->all();
DispatchCreateBeamClaimsJobs::dispatch($beam, $tokenIds->all(), $model->id)->afterCommit();
DispatchCreateBeamClaimsJobs::dispatch($beam, $tokenIds->all(), $beamPack->id)->afterCommit();
}

$tokenUploads = $tokens->whereNotNull('tokenIdDataUpload');
if ($tokenUploads->count()) {
$ids = $tokenIds->pluck('tokenIds');
$tokenUploads->each(function ($token) use ($beam, $ids, $model) {
$tokenUploads->each(function ($token) use ($beam, $ids, $beamPack) {
LazyCollection::make(function () use ($token, $ids) {
$handle = fopen($token['tokenIdDataUpload']->getPathname(), 'r');
while (($line = fgets($handle)) !== false) {
Expand All @@ -150,10 +150,10 @@ public function createPackClaims(Model $beam, array $packs, bool $isNew = false)
}
}
fclose($handle);
})->chunk(10000)->each(function (LazyCollection $tokenIds) use ($beam, $token, $model) {
})->chunk(10000)->each(function (LazyCollection $tokenIds) use ($beam, $token, $beamPack) {
$token['tokenIds'] = $tokenIds->all();
unset($token['tokenIdDataUpload']);
DispatchCreateBeamClaimsJobs::dispatch($beam, [$token], $model->id)->afterCommit();
DispatchCreateBeamClaimsJobs::dispatch($beam, [$token], $beamPack->id)->afterCommit();
unset($tokenIds, $token);
});
});
Expand Down

0 comments on commit b21e04e

Please sign in to comment.