model

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrAccountBankNotFound

func ErrAccountBankNotFound() sdk.Error

ErrAccountBankNotFound - error if account bank is not found

func ErrAccountInfoNotFound

func ErrAccountInfoNotFound() sdk.Error

ErrAccountInfoNotFound - error if account info is not found

func ErrAccountMetaNotFound

func ErrAccountMetaNotFound() sdk.Error

ErrAccountMetaNotFound - error if account meta is not found

func ErrFailedToMarshalAccountBank

func ErrFailedToMarshalAccountBank(err error) sdk.Error

ErrFailedToMarshalAccountBank - error if marshal account bank failed

func ErrFailedToMarshalAccountInfo

func ErrFailedToMarshalAccountInfo(err error) sdk.Error

ErrFailedToMarshalAccountInfo - error if marshal account info failed

func ErrFailedToMarshalAccountMeta

func ErrFailedToMarshalAccountMeta(err error) sdk.Error

ErrFailedToMarshalAccountMeta - error if marshal account meta failed

func ErrFailedToMarshalBalanceHistory

func ErrFailedToMarshalBalanceHistory(err error) sdk.Error

ErrFailedToMarshalBalanceHistory - error if marshal balance history failed

func ErrFailedToMarshalFollowerMeta

func ErrFailedToMarshalFollowerMeta(err error) sdk.Error

ErrFailedToMarshalFollowerMeta - error if marshal follower meta failed

func ErrFailedToMarshalFollowingMeta

func ErrFailedToMarshalFollowingMeta(err error) sdk.Error

ErrFailedToMarshalFollowingMeta - error if marshal following meta failed

func ErrFailedToMarshalGrantPubKey

func ErrFailedToMarshalGrantPubKey(err error) sdk.Error

ErrFailedToMarshalGrantPubKey - error if marshal grant public key failed

func ErrFailedToMarshalPendingCoinDayQueue added in v0.1.1

func ErrFailedToMarshalPendingCoinDayQueue(err error) sdk.Error

ErrFailedToMarshalPendingCoinDayQueue - error if marshal pending coin day queue failed

func ErrFailedToMarshalRelationship

func ErrFailedToMarshalRelationship(err error) sdk.Error

ErrFailedToMarshalRelationship - error if marshal relationship failed

func ErrFailedToMarshalReward

func ErrFailedToMarshalReward(err error) sdk.Error

ErrFailedToMarshalReward - error if marshal reward failed

func ErrFailedToMarshalRewardHistory

func ErrFailedToMarshalRewardHistory(err error) sdk.Error

ErrFailedToMarshalRewardHistory - error if marshal reward history failed

func ErrFailedToUnmarshalAccountBank

func ErrFailedToUnmarshalAccountBank(err error) sdk.Error

ErrFailedToUnmarshalAccountBank - error if unmarshal account bank failed

func ErrFailedToUnmarshalAccountInfo

func ErrFailedToUnmarshalAccountInfo(err error) sdk.Error

ErrFailedToUnmarshalAccountInfo - error if unmarshal account info failed

func ErrFailedToUnmarshalAccountMeta

func ErrFailedToUnmarshalAccountMeta(err error) sdk.Error

ErrFailedToUnmarshalAccountMeta - error if unmarshal account meta failed

func ErrFailedToUnmarshalBalanceHistory

func ErrFailedToUnmarshalBalanceHistory(err error) sdk.Error

ErrFailedToUnmarshalBalanceHistory - error if unmarshal balance history failed

func ErrFailedToUnmarshalGrantPubKey

func ErrFailedToUnmarshalGrantPubKey(err error) sdk.Error

ErrFailedToUnmarshalGrantPubKey - error if unmarshal grant public key failed

func ErrFailedToUnmarshalPendingCoinDayQueue added in v0.1.1

func ErrFailedToUnmarshalPendingCoinDayQueue(err error) sdk.Error

ErrFailedToUnmarshalPendingCoinDayQueue - error if unmarshal pending coin day queue failed

func ErrFailedToUnmarshalRelationship

func ErrFailedToUnmarshalRelationship(err error) sdk.Error

ErrFailedToUnmarshalRelationship - error if unmarshal relationship failed

func ErrFailedToUnmarshalReward

func ErrFailedToUnmarshalReward(err error) sdk.Error

ErrFailedToUnmarshalReward - error if unmarshal account reward failed

func ErrFailedToUnmarshalRewardHistory

func ErrFailedToUnmarshalRewardHistory(err error) sdk.Error

ErrFailedToUnmarshalRewardHistory - error if unmarshal reward history failed

func ErrGrantPubKeyNotFound

func ErrGrantPubKeyNotFound() sdk.Error

ErrGrantPubKeyNotFound - error if grant public key is not found

func ErrPendingCoinDayQueueNotFound added in v0.1.1

func ErrPendingCoinDayQueueNotFound() sdk.Error

ErrPendingCoinDayQueueNotFound - error if pending coin day queue is not found

func ErrRewardNotFound

func ErrRewardNotFound() sdk.Error

ErrRewardNotFound - error if reward is not found

func GetAccountBankKey

func GetAccountBankKey(accKey types.AccountKey) []byte

GetAccountBankKey - "account bank substore" + "username"

func GetAccountInfoKey

func GetAccountInfoKey(accKey types.AccountKey) []byte

GetAccountInfoKey - "account info substore" + "username"

func GetAccountInfoPrefix added in v0.1.1

func GetAccountInfoPrefix() []byte

GetAccountInfoPrefix - "account info substore"

func GetAccountMetaKey

func GetAccountMetaKey(accKey types.AccountKey) []byte

GetAccountMetaKey - "account meta substore" + "username"

Types

type AccountBank

type AccountBank struct {
	Saving          types.Coin    `json:"saving"`
	CoinDay         types.Coin    `json:"coin_day"`
	FrozenMoneyList []FrozenMoney `json:"frozen_money_list"`
	NumOfTx         int64         `json:"number_of_transaction"`
	NumOfReward     int64         `json:"number_of_reward"`
}

AccountBank - user balance

type AccountInfo

type AccountInfo struct {
	Username       types.AccountKey `json:"username"`
	CreatedAt      int64            `json:"created_at"`
	ResetKey       crypto.PubKey    `json:"reset_key"`
	TransactionKey crypto.PubKey    `json:"transaction_key"`
	AppKey         crypto.PubKey    `json:"app_key"`
}

AccountInfo - user information

type AccountMeta

type AccountMeta struct {
	Sequence             int64      `json:"sequence"`
	LastActivityAt       int64      `json:"last_activity_at"`
	TransactionCapacity  types.Coin `json:"transaction_capacity"`
	JSONMeta             string     `json:"json_meta"`
	LastReportOrUpvoteAt int64      `json:"last_report_or_upvote_at"`
	LastPostAt           int64      `json:"last_post_at"`
}

AccountMeta - stores tiny and frequently updated fields.

type AccountStorage

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

AccountStorage - account storage

func NewAccountStorage

func NewAccountStorage(key sdk.StoreKey) AccountStorage

NewLinoAccountStorage - creates and returns a account manager

func (AccountStorage) DeleteGrantPubKey

func (as AccountStorage) DeleteGrantPubKey(ctx sdk.Context, me types.AccountKey, pubKey crypto.PubKey)

DeleteGrantPubKey - deletes given pubkey in KV.

func (AccountStorage) DeleteRewardHistory

func (as AccountStorage) DeleteRewardHistory(ctx sdk.Context, me types.AccountKey, bucketSlot int64)

DeleteRewardHistory - delete reward history from KVStore

func (AccountStorage) DoesAccountExist

func (as AccountStorage) DoesAccountExist(ctx sdk.Context, accKey types.AccountKey) bool

DoesAccountExist - returns true when a specific account exist in the KVStore.

func (AccountStorage) GetBalanceHistory

func (as AccountStorage) GetBalanceHistory(
	ctx sdk.Context, me types.AccountKey, bucketSlot int64) (*BalanceHistory, sdk.Error)

GetRelationship - returns the relationship between two accounts

func (AccountStorage) GetBankFromAccountKey

func (as AccountStorage) GetBankFromAccountKey(
	ctx sdk.Context, me types.AccountKey) (*AccountBank, sdk.Error)

GetBankFromAccountKey - returns bank info of a specific account, returns error if any.

func (AccountStorage) GetGrantPubKey

func (as AccountStorage) GetGrantPubKey(ctx sdk.Context, me types.AccountKey, pubKey crypto.PubKey) (*GrantPubKey, sdk.Error)

GetGrantPubKey - returns grant user info keyed with pubkey.

func (AccountStorage) GetInfo

func (as AccountStorage) GetInfo(ctx sdk.Context, accKey types.AccountKey) (*AccountInfo, sdk.Error)

GetInfo - returns general account info of a specific account, returns error otherwise.

func (AccountStorage) GetMeta

func (as AccountStorage) GetMeta(ctx sdk.Context, accKey types.AccountKey) (*AccountMeta, sdk.Error)

GetMeta - returns meta of a given account that are tiny and frequently updated fields.

func (AccountStorage) GetPendingCoinDayQueue added in v0.1.1

func (as AccountStorage) GetPendingCoinDayQueue(
	ctx sdk.Context, me types.AccountKey) (*PendingCoinDayQueue, sdk.Error)

GetPendingCoinDayQueue - returns a pending coin day queue for a given address.

func (AccountStorage) GetRelationship

func (as AccountStorage) GetRelationship(ctx sdk.Context, me types.AccountKey, other types.AccountKey) (*Relationship, sdk.Error)

GetRelationship - returns the relationship between two accounts

func (AccountStorage) GetReward

func (as AccountStorage) GetReward(ctx sdk.Context, accKey types.AccountKey) (*Reward, sdk.Error)

GetReward - returns reward info of a given account, returns error if any.

func (AccountStorage) GetRewardHistory

func (as AccountStorage) GetRewardHistory(
	ctx sdk.Context, me types.AccountKey, bucketSlot int64) (*RewardHistory, sdk.Error)

GetRewardHistory - returns the history of rewards that a user received

func (AccountStorage) IsMyFollower

func (as AccountStorage) IsMyFollower(ctx sdk.Context, me types.AccountKey, follower types.AccountKey) bool

IsMyfollower - returns true if `follower` follows `me`.

func (AccountStorage) IsMyFollowing

func (as AccountStorage) IsMyFollowing(ctx sdk.Context, me types.AccountKey, following types.AccountKey) bool

IsMyFollowing - returns true if `me` follows `following`

func (AccountStorage) IterateAccounts

func (as AccountStorage) IterateAccounts(ctx sdk.Context, process func(AccountInfo, AccountBank) (stop bool))

IterateAccounts - iterate accounts in KVStore

func (AccountStorage) RemoveFollowerMeta

func (as AccountStorage) RemoveFollowerMeta(ctx sdk.Context, me types.AccountKey, follower types.AccountKey)

RemoveFollowerMeta removes follower meta info of a relationship.

func (AccountStorage) RemoveFollowingMeta

func (as AccountStorage) RemoveFollowingMeta(ctx sdk.Context, me types.AccountKey, following types.AccountKey)

RemoveFollowingMeta - removes following meta info of a relationship.

func (AccountStorage) SetBalanceHistory

func (as AccountStorage) SetBalanceHistory(
	ctx sdk.Context, me types.AccountKey, bucketSlot int64, history *BalanceHistory) sdk.Error

SetBalanceHistory - sets balance history

func (AccountStorage) SetBankFromAccountKey

func (as AccountStorage) SetBankFromAccountKey(ctx sdk.Context, username types.AccountKey, accBank *AccountBank) sdk.Error

SetBankFromAddress - sets bank info for a given address, returns error if any.

func (AccountStorage) SetFollowerMeta

func (as AccountStorage) SetFollowerMeta(ctx sdk.Context, me types.AccountKey, meta FollowerMeta) sdk.Error

SetFollowerMeta - sets follower meta info for a given account which includes time and follower name.

func (AccountStorage) SetFollowingMeta

func (as AccountStorage) SetFollowingMeta(ctx sdk.Context, me types.AccountKey, meta FollowingMeta) sdk.Error

SetFollowerMeta - sets following meta info for a given account which includes time and following name.

func (AccountStorage) SetGrantPubKey

func (as AccountStorage) SetGrantPubKey(ctx sdk.Context, me types.AccountKey, pubKey crypto.PubKey, grantPubKey *GrantPubKey) sdk.Error

SetGrantPubKey - sets a grant user to KV. Key is pubkey and value is grant user info

func (AccountStorage) SetInfo

func (as AccountStorage) SetInfo(ctx sdk.Context, accKey types.AccountKey, accInfo *AccountInfo) sdk.Error

SetInfo - sets general account info to a specific account, returns error if any.

func (AccountStorage) SetMeta

func (as AccountStorage) SetMeta(ctx sdk.Context, accKey types.AccountKey, accMeta *AccountMeta) sdk.Error

SetMeta - sets meta for a given account, returns error if any.

func (AccountStorage) SetPendingCoinDayQueue added in v0.1.1

func (as AccountStorage) SetPendingCoinDayQueue(ctx sdk.Context, me types.AccountKey, pendingCoinDayQueue *PendingCoinDayQueue) sdk.Error

SetPendingCoinDayQueue - sets a pending coin day queue for a given username.

func (AccountStorage) SetRelationship

func (as AccountStorage) SetRelationship(ctx sdk.Context, me types.AccountKey, other types.AccountKey, relationship *Relationship) sdk.Error

SetRelationship - sets relationship for two accounts

func (AccountStorage) SetReward

func (as AccountStorage) SetReward(ctx sdk.Context, accKey types.AccountKey, reward *Reward) sdk.Error

SetReward - sets the rewards info of a given account, returns error if any.

func (AccountStorage) SetRewardHistory

func (as AccountStorage) SetRewardHistory(
	ctx sdk.Context, me types.AccountKey, bucketSlot int64, history *RewardHistory) sdk.Error

SetRewardHistory - sets reward history

type BalanceHistory

type BalanceHistory struct {
	Details []Detail `json:"details"`
}

BalanceHistory - records all transactions belong to the user Currently one balance history bundle can store at most 1000 transactions If number of transaction exceeds the limitation, a new bundle will be generated in KVStore Total number of history bundle is defined in metadata

type Detail

type Detail struct {
	DetailType types.TransferDetailType `json:"detail_type"`
	From       types.AccountKey         `json:"from"`
	To         types.AccountKey         `json:"to"`
	Amount     types.Coin               `json:"amount"`
	Balance    types.Coin               `json:"balance"`
	CreatedAt  int64                    `json:"created_at"`
	Memo       string                   `json:"memo"`
}

Detail - detail of each income and outcome

type FollowerMeta

type FollowerMeta struct {
	CreatedAt    int64            `json:"created_at"`
	FollowerName types.AccountKey `json:"follower_name"`
}

FollowerMeta - record all meta info about this relation

type FollowingMeta

type FollowingMeta struct {
	CreatedAt     int64            `json:"created_at"`
	FollowingName types.AccountKey `json:"following_name"`
}

FollowingMeta - record all meta info about this relation

type FrozenMoney

type FrozenMoney struct {
	Amount   types.Coin `json:"amount"`
	StartAt  int64      `json:"start_at"`
	Times    int64      `json:"times"`
	Interval int64      `json:"interval"`
}

FrozenMoney - frozen money

type GrantPubKey

type GrantPubKey struct {
	Username   types.AccountKey `json:"username"`
	Permission types.Permission `json:"permission"`
	CreatedAt  int64            `json:"created_at"`
	ExpiresAt  int64            `json:"expires_at"`
	Amount     types.Coin       `json:"amount"`
}

GrantPubKey - user grant permission to a public key with a certain permission

type PendingCoinDay added in v0.1.1

type PendingCoinDay struct {
	StartTime int64      `json:"start_time"`
	EndTime   int64      `json:"end_time"`
	Coin      types.Coin `json:"coin"`
}

PendingCoinDay - pending coin day in the list

type PendingCoinDayQueue added in v0.1.1

type PendingCoinDayQueue struct {
	LastUpdatedAt   int64            `json:"last_updated_at"`
	TotalCoinDay    sdk.Rat          `json:"total_coin_day"`
	TotalCoin       types.Coin       `json:"total_coin"`
	PendingCoinDays []PendingCoinDay `json:"pending_coin_days"`
}

PendingCoinDayQueue - stores a list of pending coin day and total number of coin waiting in list

type Relationship

type Relationship struct {
	DonationTimes int64 `json:"donation_times"`
}

Relationship - relation between two users

type Reward

type Reward struct {
	TotalIncome     types.Coin `json:"total_income"`
	OriginalIncome  types.Coin `json:"original_income"`
	FrictionIncome  types.Coin `json:"friction_income"`
	InflationIncome types.Coin `json:"inflation_income"`
	UnclaimReward   types.Coin `json:"unclaim_reward"`
}

Reward - get from the inflation pool

type RewardDetail

type RewardDetail struct {
	OriginalDonation types.Coin       `json:"original_donation"`
	FrictionDonation types.Coin       `json:"friction_donation"`
	ActualReward     types.Coin       `json:"actual_reward"`
	Consumer         types.AccountKey `json:"consumer"`
	PostAuthor       types.AccountKey `json:"post_author"`
	PostID           string           `json:"post_id"`
}

RewardDetail - reward detail

type RewardHistory

type RewardHistory struct {
	Details []RewardDetail `json:"details"`
}

RewardHistory - reward history

Jump to

Keyboard shortcuts

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