func (k Keeper) SetPrice(
	ctx sdk.Context,
	oracle sdk.AccAddress,
	assetCode string,
	price sdk.Dec,
	expiry sdk.Int) (PostedPrice, sdk.Error) {
	if expiry.GTE(sdk.NewInt(ctx.BlockHeight())) {
		store := ctx.KVStore(k.storeKey)
		prices := k.GetRawPrices(ctx, assetCode)
		var index int
		found := false
		for i := range prices {
			if prices[i].OracleAddress == oracle.String() {
				index = i
				found = true
				break
			}
		}
		if found {
			prices[index] = PostedPrice{AssetCode: assetCode, OracleAddress: oracle.String(), Price: price, Expiry: expiry}
		} else {
			prices = append(prices, PostedPrice{
				assetCode, oracle.String(), price, expiry,
			})
			index = len(prices) - 1
		}
		store.Set(
			[]byte(RawPriceFeedPrefix+assetCode), k.cdc.MustMarshalBinaryBare(prices),
		)
		return prices[index], nil
	}
	return PostedPrice{}, ErrExpired(k.codespace)
}
SetPrice updates the posted price for a specific oracle
package pricefeed
import (
	"sort"
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
	ModuleName = "pricefeed"
	StoreKey = ModuleName
	RouterKey = ModuleName
	QuerierRoute = ModuleName
	DefaultParamspace = ModuleName
	RawPriceFeedPrefix = StoreKey + ":raw:"
	CurrentPricePrefix = StoreKey + ":currentprice:"
	AssetPrefix = StoreKey + ":assets"
	OraclePrefix = StoreKey + ":oracles"
)
type Keeper struct {
	storeKey  sdk.StoreKey
	cdc       *codec.Codec
	codespace sdk.CodespaceType
}
func NewKeeper(storeKey sdk.StoreKey, cdc *codec.Codec, codespace sdk.CodespaceType) Keeper {
	return Keeper{
		storeKey:  storeKey,
		cdc:       cdc,
		codespace: codespace,
	}
}
func (k Keeper) AddOracle(ctx sdk.Context, address string) {
	oracles := k.GetOracles(ctx)
	oracles = append(oracles, Oracle{OracleAddress: address})
	store := ctx.KVStore(k.storeKey)
	store.Set(
		[]byte(OraclePrefix), k.cdc.MustMarshalBinaryBare(oracles),
	)
}
func (k Keeper) AddAsset(
	ctx sdk.Context,
	assetCode string,
	desc string,
) {
	assets := k.GetAssets(ctx)
	assets = append(assets, Asset{AssetCode: assetCode, Description: desc})
	store := ctx.KVStore(k.storeKey)
	store.Set(
		[]byte(AssetPrefix), k.cdc.MustMarshalBinaryBare(assets),
	)
}