Documentation
¶
Index ¶
- Constants
- func NewMsgServerImpl(k Keeper, deps EligibilityCheckers) types.MsgServer
- func NewQueryServerImpl(k Keeper) types.QueryServer
- func VerifyEligibility(ctx sdk.Context, deps EligibilityCheckers, params types.Params, signer string, ...) (sdk.Coin, error)
- type EligibilityCheckers
- type IKeeper
- type Keeper
- func (k Keeper) Authority() string
- func (k Keeper) Codec() codec.BinaryCodec
- func (k Keeper) GetAggregate(ctx sdk.Context, provider string) (types.ProviderAggregate, bool)
- func (k Keeper) GetAvailability(ctx sdk.Context, provider string) (types.ProviderAvailability, bool)
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k Keeper) HasLeaseTombstone(ctx sdk.Context, leasePK string) bool
- func (k Keeper) IterateAggregates(ctx sdk.Context, cb func(types.ProviderAggregate) bool)
- func (k Keeper) IterateAvailability(ctx sdk.Context, cb func(types.ProviderAvailability) bool)
- func (k Keeper) IterateAvailabilityEvents(ctx sdk.Context, provider string, fromHeight, toHeight int64, ...)
- func (k Keeper) IterateEntriesForProvider(ctx sdk.Context, provider string, fromHeight, toHeight int64, ...)
- func (k Keeper) IterateEntriesForTenant(ctx sdk.Context, tenant string, cb func(types.ScoreEntry) bool)
- func (k Keeper) Logger(_ sdk.Context) log.Logger
- func (k Keeper) MustGetAvailabilityOrZero(ctx sdk.Context, provider string) types.ProviderAvailability
- func (k Keeper) NextAvailabilitySeq(ctx sdk.Context, provider string) uint64
- func (k Keeper) PruneOldestAvailabilityEvents(ctx sdk.Context, provider string, maxKeep uint32)
- func (k Keeper) PruneOldestEntries(ctx sdk.Context, provider string, maxKeep uint32)
- func (k Keeper) RecordAvailabilityDegraded(ctx sdk.Context, provider, source, reference string)
- func (k Keeper) RecordAvailabilityOffline(ctx sdk.Context, provider, source, reference string)
- func (k Keeper) RecordAvailabilityOnline(ctx sdk.Context, provider, source, reference string)
- func (k Keeper) SetAggregate(ctx sdk.Context, agg types.ProviderAggregate)
- func (k Keeper) SetAvailability(ctx sdk.Context, a types.ProviderAvailability)
- func (k Keeper) SetAvailabilityEvent(ctx sdk.Context, e types.AvailabilityEvent, seq uint64)
- func (k Keeper) SetEntry(ctx sdk.Context, e types.ScoreEntry)
- func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error
- func (k Keeper) StoreKey() storetypes.StoreKey
Constants ¶
const ( SortBpsDesc = "bps_desc" SortWeightDesc = "weight_desc" SortRecentDesc = "recent_desc" SortBpsAsc = "bps_asc" SortDefault = SortBpsDesc )
Sort options recognized by the Providers query.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServerImpl ¶
func NewMsgServerImpl(k Keeper, deps EligibilityCheckers) types.MsgServer
NewMsgServerImpl builds a new types.MsgServer backed by the given keeper and external dependencies. The keeper itself does not own references to the market / escrow keepers — they are injected per MsgServer instance so that the keeper's interface stays minimal.
func NewQueryServerImpl ¶
func NewQueryServerImpl(k Keeper) types.QueryServer
NewQueryServerImpl returns a types.QueryServer backed by the keeper.
func VerifyEligibility ¶
func VerifyEligibility( ctx sdk.Context, deps EligibilityCheckers, params types.Params, signer string, provider string, leaseID mv1.LeaseID, leasePK string, hasLeaseTombstone func(string) bool, ) (sdk.Coin, error)
VerifyEligibility checks the closed-lease + payment invariants required for a tenant to submit a reputation score. Returns the withdrawn amount on success (which becomes the score's weight).
All errors are typed module errors so contract / CLI consumers can distinguish them programmatically.
Types ¶
type EligibilityCheckers ¶
type EligibilityCheckers struct {
Market types.MarketKeeper
Escrow types.EscrowKeeper
Wasm types.WasmKeeper
}
EligibilityCheckers is the surface a keeper exposes to callers (the msg_server) that need to verify whether a tenant is allowed to score the lease's provider. It is split out so tests can stub the entire eligibility result without touching real market/escrow keepers.
Wasm is optional. When present it is used to extend signer authorisation: if the lease.owner is a wasm contract, that contract's admin is also accepted as a valid signer. This lets tenants that own the orchestrator contract (e.g. ha-orchestrator) submit scores from their EOA without going through a wasm execute round-trip.
type IKeeper ¶
type IKeeper interface {
Codec() codec.BinaryCodec
StoreKey() storetypes.StoreKey
Logger(sdk.Context) log.Logger
GetParams(ctx sdk.Context) types.Params
SetParams(ctx sdk.Context, p types.Params) error
Authority() string
GetAggregate(ctx sdk.Context, provider string) (types.ProviderAggregate, bool)
SetAggregate(ctx sdk.Context, agg types.ProviderAggregate)
IterateAggregates(ctx sdk.Context, cb func(types.ProviderAggregate) bool)
HasLeaseTombstone(ctx sdk.Context, leasePK string) bool
SetEntry(ctx sdk.Context, e types.ScoreEntry)
IterateEntriesForProvider(
ctx sdk.Context,
provider string,
fromHeight, toHeight int64,
cb func(types.ScoreEntry) bool,
)
IterateEntriesForTenant(
ctx sdk.Context,
tenant string,
cb func(types.ScoreEntry) bool,
)
PruneOldestEntries(ctx sdk.Context, provider string, maxKeep uint32)
// Availability lane (chain-derived from bid + health signals).
GetAvailability(ctx sdk.Context, provider string) (types.ProviderAvailability, bool)
SetAvailability(ctx sdk.Context, a types.ProviderAvailability)
IterateAvailability(ctx sdk.Context, cb func(types.ProviderAvailability) bool)
IterateAvailabilityEvents(
ctx sdk.Context,
provider string,
fromHeight, toHeight int64,
cb func(types.AvailabilityEvent) bool,
)
RecordAvailabilityOnline(ctx sdk.Context, provider, source, reference string)
RecordAvailabilityOffline(ctx sdk.Context, provider, source, reference string)
RecordAvailabilityDegraded(ctx sdk.Context, provider, source, reference string)
}
IKeeper is the public reputation keeper interface, surfaced via the app wiring so that the wasm querier and tests can take a narrow dependency rather than the concrete implementation.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper is the canonical reputation keeper.
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, logger log.Logger, authority string, ) Keeper
NewKeeper constructs a new reputation Keeper. authority is the bech32 address allowed to invoke MsgUpdateParams (typically the gov module account).
func (Keeper) Codec ¶
func (k Keeper) Codec() codec.BinaryCodec
Codec returns the binary codec used by this keeper.
func (Keeper) GetAggregate ¶
GetAggregate returns the current aggregate for a provider. If none exists, zero-value + false is returned.
func (Keeper) GetAvailability ¶
func (k Keeper) GetAvailability(ctx sdk.Context, provider string) (types.ProviderAvailability, bool)
GetAvailability returns the persisted aggregate for a provider plus a found flag. The returned struct is a copy and is safe to mutate.
func (Keeper) GetParams ¶
GetParams loads the current Params record. If no record has been persisted yet (e.g. fresh chain pre-init-genesis), the default parameter set is returned. Callers MUST NOT use this branch as a signal for "params unset" because InitGenesis always writes them.
func (Keeper) HasLeaseTombstone ¶
HasLeaseTombstone returns true iff a score has already been recorded for the given lease.
func (Keeper) IterateAggregates ¶
IterateAggregates calls cb for every persisted aggregate. cb returns true to stop iteration early.
func (Keeper) IterateAvailability ¶
IterateAvailability scans every persisted aggregate. cb may return true to stop iteration early.
func (Keeper) IterateAvailabilityEvents ¶
func (k Keeper) IterateAvailabilityEvents( ctx sdk.Context, provider string, fromHeight, toHeight int64, cb func(types.AvailabilityEvent) bool, )
IterateAvailabilityEvents scans events for a provider in chronological order. fromHeight / toHeight act as inclusive bounds; 0 disables the corresponding bound.
func (Keeper) IterateEntriesForProvider ¶
func (k Keeper) IterateEntriesForProvider( ctx sdk.Context, provider string, fromHeight, toHeight int64, cb func(types.ScoreEntry) bool, )
IterateEntriesForProvider scans entries for a provider in chronological order. fromHeight and toHeight are inclusive bounds; pass 0 for fromHeight or math.MaxInt64 for toHeight to disable the bound. cb returns true to stop iteration early.
func (Keeper) IterateEntriesForTenant ¶
func (k Keeper) IterateEntriesForTenant( ctx sdk.Context, tenant string, cb func(types.ScoreEntry) bool, )
IterateEntriesForTenant calls cb for every entry submitted by a tenant. The tenant index stores tombstones, so we resolve back to the canonical entry via the per-provider index. The order is iteration order of the underlying KV store (effectively per-provider then per-lease).
func (Keeper) MustGetAvailabilityOrZero ¶
func (k Keeper) MustGetAvailabilityOrZero(ctx sdk.Context, provider string) types.ProviderAvailability
MustGetAvailabilityOrZero returns the persisted aggregate or a fresh zero value when none exists. Used by the recording path which always writes back, so a "missing" record is just a fresh aggregate.
func (Keeper) NextAvailabilitySeq ¶
NextAvailabilitySeq returns and persists the next monotonic sequence number for the given provider. Sequence numbers disambiguate multiple events recorded at the same block height.
func (Keeper) PruneOldestAvailabilityEvents ¶
PruneOldestAvailabilityEvents trims the per-provider history to at most `maxKeep` rows. Mirrors PruneOldestEntries from state.go so the admin model is consistent across both lanes.
func (Keeper) PruneOldestEntries ¶
PruneOldestEntries enforces Params.MaxScoreHistoryPerProvider for a single provider. The aggregate is unaffected (it is computed incrementally and decoupled from history retention).
func (Keeper) RecordAvailabilityDegraded ¶
RecordAvailabilityDegraded is a soft negative: used for health signals that are not a hard offline (quorum_uncertain, partial failure). The current online window is preserved but availability_bps trends down.
func (Keeper) RecordAvailabilityOffline ¶
RecordAvailabilityOffline is the negative counterpart of RecordAvailabilityOnline. Callers MUST only invoke it when the provider was actually eligible for the action (e.g. eligible to bid on an order); skipped bids due to price, capacity or attribute filtering MUST NOT call this.
func (Keeper) RecordAvailabilityOnline ¶
RecordAvailabilityOnline is the high-level hook used by callers that observe a positive availability signal (e.g. a provider bid placement or a healthy attestation). It folds the event into the per-provider aggregate, appends an audit row, and emits an event.
The aggregate and history rows are JSON-marshaled into a dedicated KV sub-store; the proto-defined ProviderAggregate is intentionally NOT touched so this can ship without a proto migration.
func (Keeper) SetAggregate ¶
func (k Keeper) SetAggregate(ctx sdk.Context, agg types.ProviderAggregate)
SetAggregate persists the (incrementally-updated) aggregate for a provider. The keeper does not reject empty providers — callers must validate up the stack.
func (Keeper) SetAvailability ¶
func (k Keeper) SetAvailability(ctx sdk.Context, a types.ProviderAvailability)
SetAvailability persists the aggregate. Callers must set a.Provider to a non-empty bech32 — the keeper does not validate.
func (Keeper) SetAvailabilityEvent ¶
SetAvailabilityEvent persists a single history row.
func (Keeper) SetEntry ¶
func (k Keeper) SetEntry(ctx sdk.Context, e types.ScoreEntry)
SetEntry persists a single ScoreEntry. The two index tombstones (byTenant and byLease) are also written so that future eligibility checks can short-circuit.
func (Keeper) SetParams ¶
SetParams persists a new Params record after validating it. Callers (msg_server.UpdateParams, genesis.Init) are expected to enforce authority before delegating here.
func (Keeper) StoreKey ¶
func (k Keeper) StoreKey() storetypes.StoreKey
StoreKey returns the underlying KV store key.