TokensRepository can not be an actor, because in actor, there will be only 1 function to be called at a time and there is no risk of data race in TokensRepository, so actor is not needed .
The best candidate for an actor is Cache. It guarantees that data in Cache can be written serially and prevents data race.
Method getTokensWallet and checkAccountValidation must be declared in APIClient extension, because its related to data in blockchain, TokensRepository has only 1 aim: get list of supported tokens from solana's github repository.
The decoding in TokensListParser needs to be done in another thread, because the list is very big.
Solution
Add SolanaTokensRepository protocol to abstract it.
Change TokensRepository to class instead of actor.
Change Cache from class to actor.
Move methods that related to apiClient to APIClient+Extensions.swift
Add separate Task in decoding data after network request.
Problems
TokensRepository
can not be anactor
, because inactor
, there will be only 1 function to be called at a time and there is no risk of data race inTokensRepository
, soactor
is not needed .actor
isCache
. It guarantees that data inCache
can be written serially and prevents data race.getTokensWallet
andcheckAccountValidation
must be declared in APIClient extension, because its related to data in blockchain,TokensRepository
has only 1 aim: get list of supported tokens from solana's github repository.TokensListParser
needs to be done in another thread, because the list is very big.Solution
SolanaTokensRepository
protocol to abstract it.TokensRepository
toclass
instead ofactor
.Cache
fromclass
toactor
.apiClient
toAPIClient+Extensions.swift
Task
in decoding data after network request.