chore: Add x/capability docs (#11922)
* chore: Add x/capability docs * bad ident
This commit is contained in:
parent
90272e3b46
commit
137c758d57
@ -32,3 +32,4 @@ not own.
|
||||
## Stores
|
||||
|
||||
* MemStore
|
||||
* KeyStore
|
||||
|
||||
@ -3,9 +3,24 @@ order: 2
|
||||
-->
|
||||
|
||||
# State
|
||||
## In persisted KV store
|
||||
|
||||
## Index
|
||||
1. Global unique capability index
|
||||
2. Capability owners
|
||||
|
||||
## CapabilityOwners
|
||||
Indexes:
|
||||
|
||||
## Capability
|
||||
* Unique index: `[]byte("index") -> []byte(currentGlobalIndex)`
|
||||
* Capability Index: `[]byte("capability_index") | []byte(index) -> ProtocolBuffer(CapabilityOwners)`
|
||||
|
||||
## In-memory KV store
|
||||
|
||||
1. Initialized flag
|
||||
2. Mapping between the module and capability tuple and the capability name
|
||||
3. Mapping between the module and capability name and its index
|
||||
|
||||
Indexes:
|
||||
|
||||
* Initialized flag: `[]byte("mem_initialized")`
|
||||
* RevCapabilityKey: `[]byte(moduleName + "/rev/" + capabilityName) -> []byte(index)`
|
||||
* FwdCapabilityKey: `[]byte(moduleName + "/fwd/" + capabilityPointerAddress) -> []byte(capabilityName)`
|
||||
|
||||
@ -53,18 +53,19 @@ func NewApp(...) *App {
|
||||
After the keeper is created, it can be used to create scoped sub-keepers which
|
||||
are passed to other modules that can create, authenticate, and claim capabilities.
|
||||
After all the necessary scoped keepers are created and the state is loaded, the
|
||||
main capability keeper must be initialized and sealed to populate the in-memory
|
||||
state and to prevent further scoped keepers from being created.
|
||||
main capability keeper must be sealed to prevent further scoped keepers from
|
||||
being created.
|
||||
|
||||
```go
|
||||
func NewApp(...) *App {
|
||||
// ...
|
||||
|
||||
// Initialize and seal the capability keeper so all persistent capabilities
|
||||
// are loaded in-memory and prevent any further modules from creating scoped
|
||||
// Creating a scoped keeper
|
||||
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
|
||||
|
||||
// Seal the capability keeper to prevent any further modules from creating scoped
|
||||
// sub-keepers.
|
||||
ctx := app.BaseApp.NewContext(true, tmproto.Header{})
|
||||
app.capabilityKeeper.InitializeAndSeal(ctx)
|
||||
app.capabilityKeeper.Seal()
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ var (
|
||||
KeyIndex = []byte("index")
|
||||
|
||||
// KeyPrefixIndexCapability defines a key prefix that stores index to capability
|
||||
// name mappings.
|
||||
// owners mappings.
|
||||
KeyPrefixIndexCapability = []byte("capability_index")
|
||||
|
||||
// KeyMemInitialized defines the key that stores the initialized flag in the memory store
|
||||
|
||||
Loading…
Reference in New Issue
Block a user