cosmos-sdk/x/capability/alias.go
Aditya d247184157
Revert Capabilities on Failed Tx (#5999)
Reintroduce memKVStore to keep track of fwd and reverse mappings.

On reverse mapping, rather than store a mapping to marshalled
capability; we store the index.

capability.Keeper and all scopedKeeper have access to a capability
map that maps index to the capability pointer.

This is done to make sure that all writes to memKVStore get reverted
on a fail tx, while also allowing GetCapability to retrieve the original
memory pointer from the go map.

Go map must be accessed only by first going through the
memKVStore. SInce writes to go map cannot be automatically
reverted on tx failure, it gets cleaned up on failed GetCapability calls.

Closes: #5965
2020-04-16 18:42:13 +02:00

41 lines
1.1 KiB
Go

package capability
import (
"github.com/cosmos/cosmos-sdk/x/capability/keeper"
"github.com/cosmos/cosmos-sdk/x/capability/types"
)
// DONTCOVER
// nolint
const (
ModuleName = types.ModuleName
StoreKey = types.StoreKey
MemStoreKey = types.MemStoreKey
)
// nolint
var (
NewKeeper = keeper.NewKeeper
NewCapability = types.NewCapability
RevCapabilityKey = types.RevCapabilityKey
FwdCapabilityKey = types.FwdCapabilityKey
KeyIndex = types.KeyIndex
KeyPrefixIndexCapability = types.KeyPrefixIndexCapability
ErrCapabilityTaken = types.ErrCapabilityTaken
ErrOwnerClaimed = types.ErrOwnerClaimed
ErrCapabilityNotOwned = types.ErrCapabilityNotOwned
RegisterCodec = types.RegisterCodec
ModuleCdc = types.ModuleCdc
NewOwner = types.NewOwner
NewCapabilityOwners = types.NewCapabilityOwners
)
// nolint
type (
Keeper = keeper.Keeper
ScopedKeeper = keeper.ScopedKeeper
Capability = types.Capability
CapabilityOwners = types.CapabilityOwners
)