chore: Add x/capability docs (#11922)

* chore: Add x/capability docs

* bad ident
This commit is contained in:
Facundo Medica 2022-05-11 08:23:54 -03:00 committed by GitHub
parent 90272e3b46
commit 137c758d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 10 deletions

View File

@ -32,3 +32,4 @@ not own.
## Stores
* MemStore
* KeyStore

View File

@ -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)`

View File

@ -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
}

View File

@ -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