Skip to content

Commit

Permalink
fix: local values
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Jun 19, 2023
1 parent d742d5e commit 78b9f98
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
35 changes: 29 additions & 6 deletions common/store/store.setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions internal/registries/accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions internal/tokens/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions internal/vaults/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

1 comment on commit 78b9f98

@vercel
Copy link

@vercel vercel bot commented on 78b9f98 Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ydaemon – ./docs

ydaemon.yearn.farm
ydaemon-git-main.yearn.farm

Please sign in to comment.