keeper

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryPopular    = "popular"
	QueryPosts      = "posts"
	QueryUser       = "user"
	QueryLikedPosts = "liked-posts"
)

Variables

This section is empty.

Functions

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier creates a new querier for community clients.

Types

type Index

type Index interface {
	AddPost(p types.Post) error
	DeletePost(p types.Post) error
	UpdateLikes(old, new types.Post) error

	AddLike(l types.Like) error
	GetUserLikedPosts(owner sdk.AccAddress) (map[string]types.LikeWeight, error)

	GetRecentPosts(resolver func([]byte) types.Post, c types.Category, from []byte, limit uint32) ([]types.Post, error)
	GetPopularPosts(resolver func([]byte) types.Post, i Interval, c types.Category, from []byte, limit uint32) ([]types.Post, error)

	RemoveUnnecessaryPosts(ctx sdk.Context, t uint64, resolver func([]byte) types.Post)
}

func NewIndex

func NewIndex(db *bolt.DB) (Index, error)

type Interval

type Interval uint8
const (
	InvalidInterval Interval = iota
	DayInterval
	WeekInterval
	MonthInterval
)

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, index Index, tokens TokenKeeper) Keeper

NewKeeper creates new instances of the community Keeper

func (Keeper) CreatePost

func (k Keeper) CreatePost(ctx sdk.Context, p types.Post)

CreatePost creates new post. Keeper's key is joined owner and uuid.

func (Keeper) DeletePost

func (k Keeper) DeletePost(ctx sdk.Context, owner sdk.AccAddress, id uuid.UUID)

DeletePost deletes the post from keeper.

func (Keeper) GetLikeByKey

func (k Keeper) GetLikeByKey(ctx sdk.Context, key []byte) types.Like

GetLikeByKey returns entire like by keeper's key.

func (Keeper) GetLikesIterator

func (k Keeper) GetLikesIterator(ctx sdk.Context) sdk.Iterator

GetLikesIterator returns an iterator over all likes

func (Keeper) GetPostByKey

func (k Keeper) GetPostByKey(ctx sdk.Context, key []byte) types.Post

GetPostByKey returns entire post by keeper's key.

func (Keeper) GetPostsIterator

func (k Keeper) GetPostsIterator(ctx sdk.Context) sdk.Iterator

GetPostsIterator returns an iterator over all posts

func (Keeper) ListUserPosts

func (k Keeper) ListUserPosts(ctx sdk.Context, owner sdk.AccAddress, from uuid.UUID, limit uint32) []types.Post

func (Keeper) SetLike

func (k Keeper) SetLike(ctx sdk.Context, newLike types.Like)

func (Keeper) SyncIndex

func (k Keeper) SyncIndex(ctx sdk.Context)

type Post

type Post struct {
	UUID          string         `json:"uuid"`
	Owner         sdk.AccAddress `json:"owner"`
	Title         string         `json:"title"`
	PreviewImage  string         `json:"previewImage"`
	Category      types.Category `json:"category"`
	Text          string         `json:"text"`
	LikesCount    uint32         `json:"likesCount"`
	DislikesCount uint32         `json:"dislikesCount"`
	CreatedAt     uint64         `json:"createdAt"`
	PDV           float64        `json:"pdv" amino:"unsafe"`
}

type TokenKeeper

type TokenKeeper interface {
	AddTokens(ctx sdk.Context, owner sdk.AccAddress, amount sdk.Int)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL