Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Little Clarrification #716

Closed
oasin opened this issue Jun 13, 2023 · 2 comments
Closed

Little Clarrification #716

oasin opened this issue Jun 13, 2023 · 2 comments
Assignees
Labels
internal api question Further information is requested Stale

Comments

@oasin
Copy link

oasin commented Jun 13, 2023

I am doing a workaround on the library, I am having some difficulties understanding the below lines

app(RegulatorServiceInterface::class)->sync($this, $balance);

This is found in the refreshBalance method of the Wallet class, I looked up the called method in the regulator service the below code is found in the sync method

    $this->persist($wallet);
    return $this->storageService->sync(
        $wallet->uuid,
        $this->mathService->round(
            $this->mathService->negative($this->mathService->sub($this->amount($wallet), $value))
        )
    );

I believe this synchronizes the Transactions Table and update the wallet.

I am trying to replicate this by synchronizing another table and updating the wallet table but it seems not to work.

I would appreciate your time for some clarification, thanks.

@rez1dent3 rez1dent3 self-assigned this Jun 14, 2023
@rez1dent3 rez1dent3 added the question Further information is requested label Jun 14, 2023
@rez1dent3
Copy link
Member

Hello. Start by reading articles on inner workings: #412 #562 #589

The Regulator only works with the array cache, while the Bookkeeper works with the cache state. Those changes from the Regulator are applied at the end of the transaction.

$this->app->when($configure['regulator'] ?? RegulatorService::class)
->needs(StorageServiceInterface::class)
->give(function () {
return $this->app->make(
'wallet.internal.storage',
[
'cacheRepository' => clone $this->app->make(CacheFactory::class)
->store('array'),
],
);
});

@github-actions
Copy link

This issue is stale because it has been open 7 days with no activity.

@github-actions github-actions bot added the Stale label Jun 21, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal api question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants