-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1954 from lavanet/fix-vault-stake-bug
fix: vault double stake bug
- Loading branch information
Showing
10 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package types | ||
|
||
import ( | ||
fmt "fmt" | ||
|
||
"cosmossdk.io/collections" | ||
"cosmossdk.io/collections/indexes" | ||
"github.com/lavanet/lava/v5/utils" | ||
) | ||
|
||
var MetadataVaultIndexesPrefix = collections.NewPrefix([]byte("MetadataVaultIndexes/")) | ||
|
||
// ChainIdVaultIndexes defines a secondary unique index for the keeper's stakeEntriesCurrent indexed map | ||
// Normally, a current stake entry can be accessed with the primary key: [chainID, address] | ||
// The new set of indexes, ChainIdVaultIndexes, allows accessing the stake entries with [chainID, vault] | ||
type MetadataVaultIndexes struct { | ||
Index *indexes.Unique[string, string, ProviderMetadata] | ||
} | ||
|
||
func (c MetadataVaultIndexes) IndexesList() []collections.Index[string, ProviderMetadata] { | ||
return []collections.Index[string, ProviderMetadata]{c.Index} | ||
} | ||
|
||
func NewMetadataVaultIndexes(sb *collections.SchemaBuilder) MetadataVaultIndexes { | ||
return MetadataVaultIndexes{ | ||
Index: indexes.NewUnique(sb, MetadataVaultIndexesPrefix, "provider_metadata_by_vault", | ||
collections.StringKey, | ||
collections.StringKey, | ||
func(pk string, entry ProviderMetadata) (string, error) { | ||
if entry.Vault == "" { | ||
return "", | ||
utils.LavaFormatError("NewMetadataVaultIndexes: cannot create new MetadataVault index", | ||
fmt.Errorf("empty vault address"), | ||
utils.LogAttr("provider", entry.Provider), | ||
) | ||
} | ||
return entry.Vault, nil | ||
}, | ||
), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters