diff --git a/common/store/store.setter.go b/common/store/store.setter.go index 55b9c76ad..5f9a266bd 100644 --- a/common/store/store.setter.go +++ b/common/store/store.setter.go @@ -126,9 +126,8 @@ func AppendInHistoricalMap(chainID uint64, blockNumber uint64, tokenAddress comm ** access during that same execution, and will store it in the configured DB for future executions. **************************************************************************************************/ func StoreNewVaultsFromRegistry(chainID uint64, vault models.TVaultsFromRegistry) { - syncMap := _newVaultsFromRegistrySyncMap[chainID] + AppendInNewVaultsFromRegistry(chainID, vault) key := strconv.FormatUint(vault.BlockNumber, 10) + "_" + vault.RegistryAddress.Hex() + "_" + vault.Address.Hex() + "_" + vault.TokenAddress.Hex() + "_" + vault.APIVersion - syncMap.Store(key, vault) switch _dbType { case DBBadger: @@ -160,14 +159,22 @@ func StoreNewVaultsFromRegistry(chainID uint64, vault models.TVaultsFromRegistry } } +/************************************************************************************************** +** AppendInNewVaultsFromRegistry will add a new vault in the _vaultsSyncMap +**************************************************************************************************/ +func AppendInNewVaultsFromRegistry(chainID uint64, vault models.TVaultsFromRegistry) { + syncMap := _newVaultsFromRegistrySyncMap[chainID] + key := strconv.FormatUint(vault.BlockNumber, 10) + "_" + vault.RegistryAddress.Hex() + "_" + vault.Address.Hex() + "_" + vault.TokenAddress.Hex() + "_" + vault.APIVersion + syncMap.Store(key, vault) +} + /************************************************************************************************** ** StoreERC20 will store a new erc20 token in the _erc20SyncMap for fast access during that same ** execution, and will store it in the configured DB for future executions. **************************************************************************************************/ func StoreERC20(chainID uint64, token models.TERC20Token) { - syncMap := _erc20SyncMap[chainID] + AppendInERC20(chainID, token) key := token.Address.Hex() - syncMap.Store(key, token) switch _dbType { case DBBadger: @@ -205,14 +212,22 @@ func StoreERC20(chainID uint64, token models.TERC20Token) { } } +/************************************************************************************************** +** AppendInERC20 will add a new erc20 token in the _erc20SyncMap +**************************************************************************************************/ +func AppendInERC20(chainID uint64, token models.TERC20Token) { + syncMap := _erc20SyncMap[chainID] + key := token.Address.Hex() + syncMap.Store(key, token) +} + /************************************************************************************************** ** StoreVault will store a new vault in the _vaultsSyncMap for fast access during that same ** execution, and will store it in the configured DB for future executions. **************************************************************************************************/ func StoreVault(chainID uint64, vault models.TVault) { - syncMap := _vaultsSyncMap[chainID] + AppendInVaultMap(chainID, vault) key := vault.Address.Hex() + "_" + vault.Token.Address.Hex() + "_" + strconv.FormatUint(vault.Activation, 10) + "_" + strconv.FormatUint(vault.ChainID, 10) - syncMap.Store(vault.Address, vault) switch _dbType { case DBBadger: @@ -256,6 +271,14 @@ func StoreVault(chainID uint64, vault models.TVault) { } } +/************************************************************************************************** +** AppendInVaultMap will add a new vault in the _vaultsSyncMap +**************************************************************************************************/ +func AppendInVaultMap(chainID uint64, vault models.TVault) { + syncMap := _vaultsSyncMap[chainID] + syncMap.Store(vault.Address, vault) +} + /************************************************************************************************** ** StoreStrategies will store the new strategies in the _strategiesSyncMap for fast access during ** that same execution, and will store it in the configured DB for future executions. diff --git a/internal/registries/accessor.go b/internal/registries/accessor.go index f632d081b..a76e899a8 100644 --- a/internal/registries/accessor.go +++ b/internal/registries/accessor.go @@ -59,6 +59,7 @@ func RegisterAllVaults( vaultsWithActivation := events.HandleUpdateManagementOneTime(chainID, uniqueVaultsList) for _, vault := range vaultsWithActivation { + store.AppendInNewVaultsFromRegistry(chainID, vault) if _, ok := alreadyStoredVaultList[vault.Address]; !ok { store.StoreNewVaultsFromRegistry(chainID, vault) } diff --git a/internal/tokens/fetcher.go b/internal/tokens/fetcher.go index f3da61170..f7c5cd07a 100755 --- a/internal/tokens/fetcher.go +++ b/internal/tokens/fetcher.go @@ -441,6 +441,7 @@ func RetrieveAllTokens( ** func. **********************************************************************************************/ for _, token := range updatedTokenMap { + store.AppendInERC20(chainID, token) if _, ok := tokenMap[token.Address]; !ok { store.StoreERC20(chainID, token) } diff --git a/internal/vaults/fetcher.go b/internal/vaults/fetcher.go index 791727bba..5ad5d5602 100755 --- a/internal/vaults/fetcher.go +++ b/internal/vaults/fetcher.go @@ -291,6 +291,7 @@ func RetrieveAllVaults( ** of vaultAddress -> TTokens. All vaults will be retrievable from the store.Interate() func. **********************************************************************************************/ for _, vault := range updatedVaultMap { + store.AppendInVaultMap(chainID, vault) if _, ok := vaultMap[vault.Address]; !ok { store.StoreVault(chainID, vault) }