keeper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryPost = "post"
)

query endpoints supported by the magpie Querier

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(keeper Keeper) sdk.Handler

NewHandler returns a handler for "magpie" type messages.

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

Types

type Keeper

type Keeper struct {
	StoreKey sdk.StoreKey // Unexposed key to access store from sdk.Context
	Cdc      *codec.Codec // The wire codec for binary encoding/decoding.
}

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) Keeper

NewKeeper creates new instances of the magpie Keeper

func (Keeper) GetLastPostID

func (k Keeper) GetLastPostID(ctx sdk.Context) types.PostID

GetLastPostID returns the last post id that has been used

func (Keeper) GetLikes

func (k Keeper) GetLikes(ctx sdk.Context) map[types.PostID]types.Likes

GetLikes allows to returns the list of likes that have been stored inside the given context

func (Keeper) GetPost

func (k Keeper) GetPost(ctx sdk.Context, id types.PostID) (post types.Post, found bool)

GetPost returns the post having the given id inside the current context. If no post having the given id can be found inside the current context, false will be returned.

func (Keeper) GetPostChildrenIDs

func (k Keeper) GetPostChildrenIDs(ctx sdk.Context, postID types.PostID) types.PostIDs

GetPostChildrenIDs returns the IDs of all the children posts associated to the post having the given postID nolint: interfacer

func (Keeper) GetPostLikes

func (k Keeper) GetPostLikes(ctx sdk.Context, postID types.PostID) types.Likes

GetPostLikes returns the list of likes that has been associated to the post having the given id nolint: interfacer

func (Keeper) GetPosts

func (k Keeper) GetPosts(ctx sdk.Context) []types.Post

GetPosts returns the list of all the posts that are stored into the current state.

func (Keeper) RemoveLike

func (k Keeper) RemoveLike(ctx sdk.Context, postID types.PostID, liker sdk.AccAddress) sdk.Error

RemoveLike removes the liker from the given liker from the post having the given postID. If no liker was previously added from the given liker, an error is returned. nolint: interfacer

func (Keeper) SaveLike

func (k Keeper) SaveLike(ctx sdk.Context, postID types.PostID, like types.Like) sdk.Error

SaveLike allows to save the given liker inside the store. It assumes that the given liker is valid. If another liker from the same owner and for the same post exists, returns an error. nolint: interfacer

func (Keeper) SavePost

func (k Keeper) SavePost(ctx sdk.Context, post types.Post)

SavePost allows to save the given post inside the current context. It assumes that the given post has already been validated. If another post has the same ID of the given post, the old post will be overridden

type PostQueryResponse

type PostQueryResponse struct {
	types.Post
	Likes    types.Likes   `json:"likes"`
	Children types.PostIDs `json:"children"`
}

PostQueryResponse represents the data of a post that is returned to user upon a query

func NewPostResponse

func NewPostResponse(post types.Post, likes types.Likes, children types.PostIDs) PostQueryResponse

func (PostQueryResponse) MarshalJSON

func (response PostQueryResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler as Amino does not respect default json composition

Jump to

Keyboard shortcuts

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