db

package
v0.0.0-...-2f442fc Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockTable          = "Block"
	KeyTable            = "Key"
	TxOutTable          = "TxOut"
	TransactionTable    = "Transaction"
	TransactionBlockTbl = "Transaction.Block"
)
View Source
const (
	RankCountBoost int     = 60
	RankGravity    float32 = 2
)
View Source
const (
	NotificationTypeLike        = 1
	NotificationTypeReply       = 2
	NotificationTypeThreadReply = 3
	NotificationTypeNewFollower = 4
)
View Source
const (
	SettingIntegrationsAll  = "all"
	SettingIntegrationsHide = "hide"
	SettingIntegrationsNone = "none"

	SettingThemeDefault = "default"
	SettingThemeDark    = "dark"

	MaxDefaultTip = 1e9
)

Variables

Functions

func AddBlock

func AddBlock(block *Block) error

func AddUpdateTopicInfo

func AddUpdateTopicInfo(topicName string, numPosts int, followers int, recentPost time.Time) error

func AttachUnreadToTopics

func AttachUnreadToTopics(topics []*view.Topic, userPkHash []byte) error

func ContainsWatchedPkHash

func ContainsWatchedPkHash(pkHashes [][]byte) (bool, error)

func Find

func Find(out interface{}, where ...interface{}) error

func GetCountMemoFollows

func GetCountMemoFollows() (uint, error)

func GetCountMemoLikes

func GetCountMemoLikes() (uint, error)

func GetCountMemoPollOption

func GetCountMemoPollOption() (uint, error)

func GetCountMemoPollQuestion

func GetCountMemoPollQuestion() (uint, error)

func GetCountMemoPollVote

func GetCountMemoPollVote() (uint, error)

func GetCountMemoPosts

func GetCountMemoPosts() (uint, uint, uint, uint, error)

func GetCountMemoSetName

func GetCountMemoSetName() (uint, error)

func GetCountMemoSetPic

func GetCountMemoSetPic() (uint, error)

func GetCountMemoSetProfile

func GetCountMemoSetProfile() (uint, error)

func GetCountMemoTopicFollow

func GetCountMemoTopicFollow() (uint, error)

func GetCsrfTokenString

func GetCsrfTokenString(cookieId string) (string, error)

func GetFollowerCountForPkHash

func GetFollowerCountForPkHash(followPkHash []byte) (uint, error)

func GetFollowerCountForTopic

func GetFollowerCountForTopic(topic string) (uint, error)

func GetFollowingCountForPkHash

func GetFollowingCountForPkHash(pkHash []byte) (uint, error)

func GetLastNotificationId

func GetLastNotificationId(userId uint) (uint, error)

func GetLastTopicPostId

func GetLastTopicPostId(userPkHash []byte, topic string) (uint, error)

func GetMemoCohortStats

func GetMemoCohortStats() ([]view.MemoCohortStat, error)

func GetMemoTopicFollowCountForUser

func GetMemoTopicFollowCountForUser(pkHash []byte) (uint, error)

func GetPersonalizedRecentTopLikedTxHashes

func GetPersonalizedRecentTopLikedTxHashes(selfPkHash []byte, offset uint, timeStart time.Time, timeEnd time.Time) ([][]byte, error)

func GetPostReplyCount

func GetPostReplyCount(txHash []byte) (uint, error)

func GetRecentTopLikedTxHashes

func GetRecentTopLikedTxHashes(offset uint, timeStart time.Time, timeEnd time.Time) ([][]byte, error)

func GetThreads

func GetThreads(offset uint, topic string) ([]*view.Thread, error)

func GetTopicInfo

func GetTopicInfo(offset uint, searchString string, pkHash []byte, orderType view.TopicOrderType) ([]*view.Topic, error)

func GetTopicInfoFromPosts

func GetTopicInfoFromPosts(topicNames ...string) ([]*view.Topic, error)

func GetUniqueMemoAPkHashes

func GetUniqueMemoAPkHashes(offset int, searchString string, orderType UserStatOrderType) ([]*view.Profile, error)

func GetUniqueMemoAPkHashesMatchName

func GetUniqueMemoAPkHashesMatchName(searchString string, offset int) ([][]byte, error)

func GetUniqueUserCount

func GetUniqueUserCount() (int, error)

func GetUnreadNotificationCount

func GetUnreadNotificationCount(pkHash []byte, lastNotificationId uint) (uint, error)

func GetUserFirstPostStats

func GetUserFirstPostStats() ([]view.UserDateStat, error)

func GetUserIdFromPkHash

func GetUserIdFromPkHash(pkHash []byte) (uint, error)

func GetUserStats

func GetUserStats() ([]view.UserStat, error)

func HasSpendable

func HasSpendable(pkHash []byte) (bool, error)

func IsAlreadyExistsError

func IsAlreadyExistsError(e error) bool

func IsDuplicateEntryError

func IsDuplicateEntryError(e error) bool

func IsFollowing

func IsFollowing(followerPkHash []byte, followingPkHash []byte) (bool, error)

func IsFollowingTopic

func IsFollowingTopic(pkHash []byte, topic string) (bool, error)

func IsNoRowsInResultSetError

func IsNoRowsInResultSetError(e error) bool

func IsRecordNotFoundError

func IsRecordNotFoundError(e error) bool

func IsValidDefaultTip

func IsValidDefaultTip(defaultTip uint) bool

func IsValidIntegrationsSetting

func IsValidIntegrationsSetting(integrations string) bool

func IsValidThemeSetting

func IsValidThemeSetting(theme string) bool

func Save

func Save(value interface{}) error

func SaveBlocks

func SaveBlocks(blocks []*Block) error

func SetLastNotificationId

func SetLastNotificationId(userId uint, lastNotificationId uint) error

func SetLastTopicPostId

func SetLastTopicPostId(userPkHash []byte, topic string, lastPostId uint) error

func ToSnake

func ToSnake(in string) string

func UpdateCsrfTokenSession

func UpdateCsrfTokenSession(oldCookieId string, newCookieId string) error

Types

type Block

type Block struct {
	Id         uint `gorm:"primary_key"`
	Height     uint `gorm:"unique"`
	Timestamp  time.Time
	Hash       []byte `gorm:"unique"`
	PrevBlock  []byte
	MerkleRoot []byte
	Nonce      uint32
	TxnCount   uint32
	Version    int32
	Bits       uint32
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func ConvertMessageHeaderToBlock

func ConvertMessageHeaderToBlock(header *wire.BlockHeader) *Block

func GetBlockByHash

func GetBlockByHash(hash chainhash.Hash) (*Block, error)

func GetBlockByHeight

func GetBlockByHeight(height uint) (*Block, error)

func GetBlocksInHeightRange

func GetBlocksInHeightRange(startHeight uint, endHeight uint) ([]*Block, error)

func GetGenesis

func GetGenesis() (*Block, error)

func GetRecentBlock

func GetRecentBlock() (*Block, error)

func (Block) GetChainhash

func (b Block) GetChainhash() *chainhash.Hash

func (Block) GetMerkleRoot

func (b Block) GetMerkleRoot() *chainhash.Hash

func (Block) GetPrevBlockChainhash

func (b Block) GetPrevBlockChainhash() *chainhash.Hash

func (Block) NextHeight

func (b Block) NextHeight() uint

func (Block) PrevHeight

func (b Block) PrevHeight() uint

func (*Block) Save

func (b *Block) Save() error

type CsrfToken

type CsrfToken struct {
	Id        uint   `gorm:"primary_key"`
	CookieId  string `gorm:"unique;size:140"`
	Token     string `gorm:"unique;size:140"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func GetCsrfToken

func GetCsrfToken(cookieId string) (*CsrfToken, error)

func (*CsrfToken) Save

func (c *CsrfToken) Save() error

type FeedEvent

type FeedEvent struct {
	Id          uint   `gorm:"primary_key"`
	Block       *Block `gorm:"foreignkey:BlockHeight"`
	BlockHeight uint   `gorm:"index:block_height"`
	PkHash      []byte `gorm:"index:pk_hash"`
	TxHash      []byte `gorm:"unique"`
	EventType   FeedEventType
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func GetFeedByTxHash

func GetFeedByTxHash(txHash []byte) (*FeedEvent, error)

func GetRecentFeedEvents

func GetRecentFeedEvents(offset uint) ([]*FeedEvent, error)

func GetRecentFeedForPkHash

func GetRecentFeedForPkHash(pkHash []byte, offset uint) ([]*FeedEvent, error)

func GetRecentFeedUserEvents

func GetRecentFeedUserEvents(pkHash []byte, offset uint, eventTypes []FeedEventType) ([]*FeedEvent, error)

func (FeedEvent) GetAddress

func (f FeedEvent) GetAddress() wallet.Address

func (FeedEvent) GetTransactionHashString

func (f FeedEvent) GetTransactionHashString() string

func (*FeedEvent) Save

func (f *FeedEvent) Save() error

type FeedEventType

type FeedEventType int
const (
	FeedEventPost          FeedEventType = 1
	FeedEventReply         FeedEventType = 2
	FeedEventLike          FeedEventType = 3
	FeedEventTopicPost     FeedEventType = 4
	FeedEventCreatePoll    FeedEventType = 5
	FeedEventPollVote      FeedEventType = 6
	FeedEventSetName       FeedEventType = 7
	FeedEventSetProfile    FeedEventType = 8
	FeedEventSetProfilePic FeedEventType = 9
	FeedEventFollowUser    FeedEventType = 10
	FeedEventFollowTopic   FeedEventType = 11
)

type Key

type Key struct {
	Id        uint `gorm:"primary_key"`
	Name      string
	UserId    uint
	Value     []byte
	PublicKey []byte `gorm:"unique"`
	PkHash    []byte `gorm:"unique"`
	MaxCheck  uint   // maximum block height checked for transactions
	MinCheck  uint   // minimum block height checked for transactions
	CreatedAt time.Time
	UpdatedAt time.Time
}

func GenerateKey

func GenerateKey(name string, password string, userId uint) (*Key, error)

func GetAllKeys

func GetAllKeys() ([]*Key, error)

func GetKey

func GetKey(id uint, userId uint) (*Key, error)

func GetKeyForUser

func GetKeyForUser(userId uint) (*Key, error)

func GetKeyFromPublicKey

func GetKeyFromPublicKey(publicKey []byte) (*Key, error)

func GetKeysForUser deprecated

func GetKeysForUser(userId uint) ([]*Key, error)

Deprecated: Only one key per user now

func ImportKey

func ImportKey(name string, password string, wif string, userId uint) (*Key, error)

func (Key) Delete

func (k Key) Delete() error

func (Key) GetAddress

func (k Key) GetAddress() wallet.Address

func (Key) GetPrivateKey

func (k Key) GetPrivateKey(password string) (*wallet.PrivateKey, error)

func (Key) GetPublicKey

func (k Key) GetPublicKey() wallet.PublicKey

func (*Key) Save

func (k *Key) Save() error

func (*Key) UpdatePassword

func (k *Key) UpdatePassword(oldPassword string, newPassword string) error

type MemoFollow

type MemoFollow struct {
	Id           uint   `gorm:"primary_key"`
	TxHash       []byte `gorm:"unique;size:50"`
	ParentHash   []byte
	PkHash       []byte `gorm:"index:pk_hash;index:pk_hash_follow"`
	PkScript     []byte
	Address      string
	FollowPkHash []byte `gorm:"index:follow_pk_hash;index:pk_hash_follow"`
	BlockId      uint
	Block        *Block
	Unfollow     bool
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func GetAllFollows

func GetAllFollows(offset uint) ([]*MemoFollow, error)

func GetFollowersForPkHash

func GetFollowersForPkHash(pkHash []byte, offset int) ([]*MemoFollow, error)

func GetFollowingForPkHash

func GetFollowingForPkHash(followPkHash []byte, offset int) ([]*MemoFollow, error)

func GetMemoFollow

func GetMemoFollow(txHash []byte) (*MemoFollow, error)

func GetMemoFollowsByTxHashes

func GetMemoFollowsByTxHashes(txHashes [][]byte) ([]*MemoFollow, error)

func (MemoFollow) GetAddressString

func (m MemoFollow) GetAddressString() string

func (MemoFollow) GetFollowAddressString

func (m MemoFollow) GetFollowAddressString() string

func (MemoFollow) GetScriptString

func (m MemoFollow) GetScriptString() string

func (MemoFollow) GetTimeString

func (m MemoFollow) GetTimeString() string

func (MemoFollow) GetTransactionHashString

func (m MemoFollow) GetTransactionHashString() string

func (MemoFollow) Save

func (m MemoFollow) Save() error

type MemoLike

type MemoLike struct {
	Id         uint   `gorm:"primary_key"`
	TxHash     []byte `gorm:"unique;size:50"`
	ParentHash []byte
	PkHash     []byte `gorm:"index:pk_hash"`
	PkScript   []byte
	Address    string
	LikeTxHash []byte `gorm:"index:like_tx_hash"`
	TipAmount  int64
	TipPkHash  []byte
	BlockId    uint
	Block      *Block
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetLikes

func GetLikes(offset uint) ([]*MemoLike, error)

func GetMemoLike

func GetMemoLike(txHash []byte) (*MemoLike, error)

func GetMemoLikesByTxHashes

func GetMemoLikesByTxHashes(txHashes [][]byte) ([]*MemoLike, error)

func GetMemoLikesForPkHash

func GetMemoLikesForPkHash(pkHash []byte) ([]*MemoLike, error)

func GetMemoLikesForTxnHash

func GetMemoLikesForTxnHash(txHash []byte) ([]*MemoLike, error)

func GetRecentLikes

func GetRecentLikes(offset uint) ([]*MemoLike, error)

func GetRecentLikesForTopic

func GetRecentLikesForTopic(topic string, lastLikeId uint) ([]*MemoLike, error)

func (MemoLike) GetAddressString

func (m MemoLike) GetAddressString() string

func (MemoLike) GetLikeTransactionHashString

func (m MemoLike) GetLikeTransactionHashString() string

func (MemoLike) GetScriptString

func (m MemoLike) GetScriptString() string

func (MemoLike) GetTimeString

func (m MemoLike) GetTimeString() string

func (MemoLike) GetTransactionHashString

func (m MemoLike) GetTransactionHashString() string

func (MemoLike) Save

func (m MemoLike) Save() error

type MemoPollOption

type MemoPollOption struct {
	Id         uint   `gorm:"primary_key"`
	TxHash     []byte `gorm:"unique;size:50"`
	ParentHash []byte
	PkHash     []byte `gorm:"index:pk_hash"`
	PkScript   []byte
	PollTxHash []byte `gorm:"index:poll_tx_hash"`
	Option     string `gorm:"size:500"`
	BlockId    uint
	Block      *Block
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetMemoPollOption

func GetMemoPollOption(txHash []byte) (*MemoPollOption, error)

func GetMemoPollOptionByOption

func GetMemoPollOptionByOption(pollTxHash []byte, option string) (*MemoPollOption, error)

func GetMemoPollOptionsByTxHashes

func GetMemoPollOptionsByTxHashes(txHashes [][]byte) ([]*MemoPollOption, error)

func (MemoPollOption) GetAddress

func (m MemoPollOption) GetAddress() wallet.Address

func (MemoPollOption) GetAddressString

func (m MemoPollOption) GetAddressString() string

func (MemoPollOption) GetPollTransactionHashString

func (m MemoPollOption) GetPollTransactionHashString() string

func (MemoPollOption) GetTransactionHashString

func (m MemoPollOption) GetTransactionHashString() string

func (MemoPollOption) Save

func (m MemoPollOption) Save() error

type MemoPollQuestion

type MemoPollQuestion struct {
	Id         uint              `gorm:"primary_key"`
	TxHash     []byte            `gorm:"key;size:50"`
	Options    []*MemoPollOption `gorm:"foreignkey:PollTxHash;associationforeignkey:TxHash"`
	NumOptions uint
	PollType   int
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetMemoPollQuestion

func GetMemoPollQuestion(txHash []byte) (*MemoPollQuestion, error)

func GetMemoPollQuestions

func GetMemoPollQuestions(txHashes [][]byte) ([]*MemoPollQuestion, error)

func (MemoPollQuestion) GetTransactionHashString

func (m MemoPollQuestion) GetTransactionHashString() string

func (MemoPollQuestion) Save

func (m MemoPollQuestion) Save() error

type MemoPollVote

type MemoPollVote struct {
	Id           uint   `gorm:"primary_key"`
	TxHash       []byte `gorm:"unique;size:50"`
	ParentHash   []byte
	PkHash       []byte `gorm:"index:pk_hash"`
	PkScript     []byte
	BlockId      uint
	Block        *Block
	OptionTxHash []byte `gorm:"index:option_tx_hash"`
	TipAmount    int64
	TipPkHash    []byte
	Message      string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func GetMemoPollVote

func GetMemoPollVote(txHash []byte) (*MemoPollVote, error)

func GetMemoPollVotesByTxHashes

func GetMemoPollVotesByTxHashes(txHashes [][]byte) ([]*MemoPollVote, error)

func GetPollVotes

func GetPollVotes(offset uint) ([]*MemoPollVote, error)

func GetVotesForOptions

func GetVotesForOptions(questionTxHash []byte, single bool) ([]*MemoPollVote, error)

func (MemoPollVote) GetAddress

func (m MemoPollVote) GetAddress() wallet.Address

func (MemoPollVote) GetAddressString

func (m MemoPollVote) GetAddressString() string

func (MemoPollVote) GetTransactionHashString

func (m MemoPollVote) GetTransactionHashString() string

func (MemoPollVote) Save

func (m MemoPollVote) Save() error

type MemoPost

type MemoPost struct {
	Id           uint   `gorm:"primary_key"`
	TxHash       []byte `gorm:"unique;size:50"`
	ParentHash   []byte
	PkHash       []byte `gorm:"index:pk_hash"`
	PkScript     []byte `gorm:"size:500"`
	Address      string
	ParentTxHash []byte `gorm:"index:parent_tx_hash"`
	Parent       *MemoPost
	RootTxHash   []byte      `gorm:"index:root_tx_hash"`
	Replies      []*MemoPost `gorm:"foreignkey:ParentTxHash"`
	Topic        string      `gorm:"index:tag;size:500"`
	Message      string      `gorm:"size:500"`
	IsPoll       bool
	IsVote       bool
	BlockId      uint
	Block        *Block
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func GetMemoPost

func GetMemoPost(txHash []byte) (*MemoPost, error)

func GetMemoPostById

func GetMemoPostById(id uint) (*MemoPost, error)

func GetOlderPostsForTopic

func GetOlderPostsForTopic(topic string, firstPostId uint) ([]*MemoPost, error)

func GetPersonalizedTopPosts

func GetPersonalizedTopPosts(selfPkHash []byte, offset uint, timeStart time.Time, timeEnd time.Time) ([]*MemoPost, error)

func GetPollsPosts

func GetPollsPosts(offset uint) ([]*MemoPost, error)

func GetPostReplies

func GetPostReplies(txHash []byte, offset uint) ([]*MemoPost, error)

func GetPosts

func GetPosts(offset uint) ([]*MemoPost, error)

func GetPostsByTxHashes

func GetPostsByTxHashes(txHashes [][]byte) ([]*MemoPost, error)

func GetPostsFeedForPkHash

func GetPostsFeedForPkHash(pkHash []byte, offset uint) ([]*MemoPost, error)

func GetPostsForPkHash

func GetPostsForPkHash(pkHash []byte, offset uint) ([]*MemoPost, error)

func GetPostsForTopic

func GetPostsForTopic(topic string, offset uint) ([]*MemoPost, error)

func GetRankedPosts

func GetRankedPosts(offset uint, searchString string) ([]*MemoPost, error)

func GetRecentPosts

func GetRecentPosts(offset uint, searchString string) ([]*MemoPost, error)

func GetRecentPostsForTopic

func GetRecentPostsForTopic(topic string, lastPostId uint) ([]*MemoPost, error)

func GetRecentReplyPosts

func GetRecentReplyPosts(offset uint) ([]*MemoPost, error)

func GetTopPosts

func GetTopPosts(offset uint, timeStart time.Time, timeEnd time.Time) ([]*MemoPost, error)

func (MemoPost) GetAddress

func (m MemoPost) GetAddress() wallet.Address

func (MemoPost) GetAddressString

func (m MemoPost) GetAddressString() string

func (MemoPost) GetMessage

func (m MemoPost) GetMessage() string

func (MemoPost) GetParentTransactionHashString

func (m MemoPost) GetParentTransactionHashString() string

func (MemoPost) GetRootTransactionHashString

func (m MemoPost) GetRootTransactionHashString() string

func (MemoPost) GetScriptString

func (m MemoPost) GetScriptString() string

func (MemoPost) GetTimeString

func (m MemoPost) GetTimeString() string

func (MemoPost) GetTransactionHashString

func (m MemoPost) GetTransactionHashString() string

func (MemoPost) GetUrlEncodedTopic

func (m MemoPost) GetUrlEncodedTopic() string

func (*MemoPost) Save

func (m *MemoPost) Save() error

type MemoSetName

type MemoSetName struct {
	Id         uint   `gorm:"primary_key"`
	TxHash     []byte `gorm:"unique;size:50"`
	ParentHash []byte
	PkHash     []byte `gorm:"index:pk_hash"`
	PkScript   []byte `gorm:"size:500"`
	Address    string
	Name       string `gorm:"size:500"`
	BlockId    uint
	Block      *Block
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetMemoSetName

func GetMemoSetName(txHash []byte) (*MemoSetName, error)

func GetMemoSetNameById

func GetMemoSetNameById(id uint) (*MemoSetName, error)

func GetNameForPkHash

func GetNameForPkHash(pkHash []byte) (*MemoSetName, error)

func GetNamesForPkHashes

func GetNamesForPkHashes(pkHashes [][]byte) ([]*MemoSetName, error)

func GetSetNames

func GetSetNames(offset uint) ([]*MemoSetName, error)

func GetSetNamesByTxHashes

func GetSetNamesByTxHashes(txHashes [][]byte) ([]*MemoSetName, error)

func (MemoSetName) GetAddressString

func (m MemoSetName) GetAddressString() string

func (MemoSetName) GetScriptString

func (m MemoSetName) GetScriptString() string

func (MemoSetName) GetTimeString

func (m MemoSetName) GetTimeString() string

func (MemoSetName) GetTransactionHashString

func (m MemoSetName) GetTransactionHashString() string

func (MemoSetName) Save

func (m MemoSetName) Save() error

type MemoSetPic

type MemoSetPic struct {
	Id         uint   `gorm:"primary_key"`
	TxHash     []byte `gorm:"unique;size:50"`
	ParentHash []byte
	PkHash     []byte `gorm:"index:pk_hash"`
	PkScript   []byte `gorm:"size:500"`
	Address    string
	Url        string `gorm:"size:500"`
	BlockId    uint
	Block      *Block
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetMemoSetPic

func GetMemoSetPic(txHash []byte) (*MemoSetPic, error)

func GetMemoSetPicById

func GetMemoSetPicById(id uint) (*MemoSetPic, error)

func GetPicForPkHash

func GetPicForPkHash(pkHash []byte) (*MemoSetPic, error)

func GetPicsForPkHashes

func GetPicsForPkHashes(pkHashes [][]byte) ([]*MemoSetPic, error)

func GetSetProfilePics

func GetSetProfilePics(offset uint) ([]*MemoSetPic, error)

func GetSetProfilePicsByTxHashes

func GetSetProfilePicsByTxHashes(txHashes [][]byte) ([]*MemoSetPic, error)

func (MemoSetPic) GetAddressString

func (m MemoSetPic) GetAddressString() string

func (MemoSetPic) GetExtension

func (m MemoSetPic) GetExtension() string

func (MemoSetPic) GetScriptString

func (m MemoSetPic) GetScriptString() string

func (MemoSetPic) GetTimeString

func (m MemoSetPic) GetTimeString() string

func (MemoSetPic) GetTransactionHashString

func (m MemoSetPic) GetTransactionHashString() string

func (MemoSetPic) Save

func (m MemoSetPic) Save() error

type MemoSetProfile

type MemoSetProfile struct {
	Id         uint   `gorm:"primary_key"`
	TxHash     []byte `gorm:"unique;size:50"`
	ParentHash []byte
	PkHash     []byte `gorm:"index:pk_hash"`
	PkScript   []byte `gorm:"size:500"`
	Address    string
	Profile    string `gorm:"size:500"`
	BlockId    uint
	Block      *Block
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetMemoSetProfile

func GetMemoSetProfile(txHash []byte) (*MemoSetProfile, error)

func GetMemoSetProfileById

func GetMemoSetProfileById(id uint) (*MemoSetProfile, error)

func GetProfileForPkHash

func GetProfileForPkHash(pkHash []byte) (*MemoSetProfile, error)

func GetSetProfiles

func GetSetProfiles(offset uint) ([]*MemoSetProfile, error)

func GetSetProfilesByTxHashes

func GetSetProfilesByTxHashes(txHashes [][]byte) ([]*MemoSetProfile, error)

func GetSetProfilesForPkHash

func GetSetProfilesForPkHash(pkHash []byte) ([]*MemoSetProfile, error)

func (MemoSetProfile) GetAddressString

func (m MemoSetProfile) GetAddressString() string

func (MemoSetProfile) GetScriptString

func (m MemoSetProfile) GetScriptString() string

func (MemoSetProfile) GetTimeString

func (m MemoSetProfile) GetTimeString() string

func (MemoSetProfile) GetTransactionHashString

func (m MemoSetProfile) GetTransactionHashString() string

func (MemoSetProfile) Save

func (m MemoSetProfile) Save() error

type MemoTest

type MemoTest struct {
	Id        uint   `gorm:"primary_key"`
	TxHash    []byte `gorm:"unique;size:50"`
	PkHash    []byte
	PkScript  []byte `gorm:"size:500"`
	Address   string
	BlockId   uint
	Block     *Block
	CreatedAt time.Time
	UpdatedAt time.Time
}

func GetMemoTest

func GetMemoTest(txHash []byte) (*MemoTest, error)

func (MemoTest) GetAddressString

func (m MemoTest) GetAddressString() string

func (MemoTest) GetCode

func (m MemoTest) GetCode() string

func (MemoTest) GetScriptString

func (m MemoTest) GetScriptString() string

func (MemoTest) GetTransactionHashString

func (m MemoTest) GetTransactionHashString() string

func (MemoTest) Save

func (m MemoTest) Save() error

type MemoTopicFollow

type MemoTopicFollow struct {
	Id         uint   `gorm:"primary_key"`
	TxHash     []byte `gorm:"unique;size:50"`
	ParentHash []byte
	PkHash     []byte `gorm:"index:pk_hash"`
	PkScript   []byte
	Topic      string `gorm:"index:topic"`
	BlockId    uint
	Block      *Block
	Unfollow   bool
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetFollowersForTopic

func GetFollowersForTopic(topic string) ([]*MemoTopicFollow, error)

func GetMemoTopicFollow

func GetMemoTopicFollow(txHash []byte) (*MemoTopicFollow, error)

func GetMemoTopicFollowsByTxHashes

func GetMemoTopicFollowsByTxHashes(txHashes [][]byte) ([]*MemoTopicFollow, error)

func GetTopicFollows

func GetTopicFollows(offset uint) ([]*MemoTopicFollow, error)

func (MemoTopicFollow) GetScriptString

func (m MemoTopicFollow) GetScriptString() string

func (MemoTopicFollow) GetTimeString

func (m MemoTopicFollow) GetTimeString() string

func (MemoTopicFollow) GetTransactionHashString

func (m MemoTopicFollow) GetTransactionHashString() string

func (MemoTopicFollow) Save

func (m MemoTopicFollow) Save() error

type NodeStatus

type NodeStatus struct {
	Id            uint `gorm:"primary_key"`
	HeightChecked uint
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

func GetNodeStatus

func GetNodeStatus() (*NodeStatus, error)

func (*NodeStatus) Save

func (s *NodeStatus) Save() error

type Notification

type Notification struct {
	Id        uint   `gorm:"primary_key"`
	PkHash    []byte `gorm:"not null;unique_index:pk_hash_tx_hash"`
	TxHash    []byte `gorm:"not null;unique_index:pk_hash_tx_hash"`
	Type      uint
	CreatedAt time.Time
	UpdatedAt time.Time
}

func AddNotification

func AddNotification(pkHash []byte, txHash []byte, notificationType uint) (*Notification, error)

func GetRecentNotificationsForUser

func GetRecentNotificationsForUser(pkHash []byte, offset uint) ([]*Notification, error)

type Peer

type Peer struct {
	Id        uint   `gorm:"primary_key"`
	IP        []byte `gorm:"unique_index:ip_port"`
	Port      uint16 `gorm:"unique_index:ip_port"`
	Services  uint64
	Address   string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*Peer) GetAddress

func (p *Peer) GetAddress() string

func (*Peer) GetServices

func (p *Peer) GetServices() string

type Session

type Session struct {
	Id           uint   `gorm:"primary_key"`
	CookieId     string `gorm:"unique;size:140"`
	HasLoggedOut bool
	UserId       uint
	StartTs      uint
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func GetSession

func GetSession(cookieId string) (*Session, error)

func (*Session) Save

func (s *Session) Save() error

type TopicInfo

type TopicInfo struct {
	Id            uint `gorm:"primary_key"`
	TopicName     string
	PostCount     int
	FollowerCount int
	RecentPost    time.Time
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

type Transaction

type Transaction struct {
	Id        uint `gorm:"primary_key"`
	BlockId   uint
	Block     *Block
	Hash      []byte `gorm:"unique;"`
	Version   int32
	TxIn      []*TransactionIn  `gorm:"foreignkey:TransactionHash"`
	TxOut     []*TransactionOut `gorm:"foreignkey:TransactionHash"`
	LockTime  uint32
	CreatedAt time.Time
	UpdatedAt time.Time
}

func ConvertMsgToTransaction

func ConvertMsgToTransaction(msg *wire.MsgTx) (*Transaction, error)

func GetTransactionByHash

func GetTransactionByHash(hash []byte) (*Transaction, error)

func GetTransactionByHashWithOutputs

func GetTransactionByHashWithOutputs(hash []byte) (*Transaction, error)

func (*Transaction) Delete

func (t *Transaction) Delete() error

func (*Transaction) GetBlockHeight

func (t *Transaction) GetBlockHeight() string

func (*Transaction) GetBlockTime

func (t *Transaction) GetBlockTime() string

func (*Transaction) GetChainHash

func (t *Transaction) GetChainHash() *chainhash.Hash

func (*Transaction) GetFee

func (t *Transaction) GetFee() int64

func (*Transaction) GetFeeBCH

func (t *Transaction) GetFeeBCH() float64

func (*Transaction) GetKeyId

func (t *Transaction) GetKeyId() uint

func (*Transaction) GetValues

func (t *Transaction) GetValues() map[string]*Value

func (*Transaction) HasFee

func (t *Transaction) HasFee() bool

func (*Transaction) HasUserKey

func (t *Transaction) HasUserKey(userId uint) bool

func (*Transaction) Save

func (t *Transaction) Save() error

type TransactionIn

type TransactionIn struct {
	Id                    uint `gorm:"primary_key"`
	Index                 uint
	HashString            string `gorm:"index:hash_string"`
	TransactionHash       []byte
	Transaction           *Transaction `gorm:"foreignkey:TransactionHash"`
	KeyPkHash             []byte       `gorm:"index:pk_hash"`
	Key                   *Key         `gorm:"foreignkey:KeyPkHash"`
	PreviousOutPointHash  []byte       `gorm:"unique_index:previous_out"`
	PreviousOutPointIndex uint32       `gorm:"unique_index:previous_out"`
	SignatureScript       []byte
	UnlockString          string
	Sequence              uint32
	TxnOutHashString      string          `gorm:"size:4096"`
	TxnOut                *TransactionOut `gorm:"foreignkey:TxnOutHashString"`
	CreatedAt             time.Time
	UpdatedAt             time.Time
}

func GetTransactionInput

func GetTransactionInput(txHash []byte, index uint32) (*TransactionIn, error)

func GetTransactionInputByHashString

func GetTransactionInputByHashString(hashString string) (*TransactionIn, error)

func (TransactionIn) Delete

func (t TransactionIn) Delete() error

func (TransactionIn) GetAddress

func (t TransactionIn) GetAddress() wallet.Address

func (TransactionIn) GetAddressString

func (t TransactionIn) GetAddressString() string

func (TransactionIn) GetHashString

func (t TransactionIn) GetHashString() string

func (TransactionIn) GetOutPoint

func (t TransactionIn) GetOutPoint() *wire.OutPoint

func (*TransactionIn) GetPkHash

func (t *TransactionIn) GetPkHash() []byte

func (TransactionIn) GetPrevOutPointHash

func (t TransactionIn) GetPrevOutPointHash() []byte

func (TransactionIn) GetPrevOutPointString

func (t TransactionIn) GetPrevOutPointString() string

func (TransactionIn) GetPublicKey

func (t TransactionIn) GetPublicKey() []byte

func (TransactionIn) HasOut

func (t TransactionIn) HasOut() bool

func (TransactionIn) Save

func (t TransactionIn) Save() error

type TransactionOut

type TransactionOut struct {
	Id              uint   `gorm:"primary_key"`
	Index           uint32 `gorm:"unique_index:transaction_out_index;"`
	HashString      string
	TransactionHash []byte       `gorm:"unique_index:transaction_out_index;"`
	Transaction     *Transaction `gorm:"foreignkey:TransactionHash"`
	KeyPkHash       []byte       `gorm:"index:pk_hash"`
	Key             *Key         `gorm:"foreignkey:KeyPkHash"`
	Value           int64
	PkScript        []byte
	LockString      string
	RequiredSigs    uint
	ScriptClass     uint
	TxnInHashString string         `gorm:"index:txn_in_hash_string"`
	TxnIn           *TransactionIn `gorm:"foreignkey:TxnInHashString"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

func GetSpendableTransactionOutputsForPkHash

func GetSpendableTransactionOutputsForPkHash(pkHash []byte) ([]*TransactionOut, error)

func GetTransactionOutput

func GetTransactionOutput(txHash []byte, index uint32) (*TransactionOut, error)

func (TransactionOut) GetAddressString

func (t TransactionOut) GetAddressString() string

func (TransactionOut) GetHashString

func (t TransactionOut) GetHashString() string

func (TransactionOut) GetMessage

func (t TransactionOut) GetMessage() string

func (TransactionOut) GetPkHash

func (t TransactionOut) GetPkHash() []byte

func (TransactionOut) GetScriptClass

func (t TransactionOut) GetScriptClass() string

func (TransactionOut) HasIn

func (t TransactionOut) HasIn() bool

func (TransactionOut) IsMemo

func (t TransactionOut) IsMemo() bool

func (TransactionOut) IsSpendable

func (t TransactionOut) IsSpendable() bool

func (TransactionOut) Save

func (t TransactionOut) Save() error

func (TransactionOut) ValueInBCH

func (t TransactionOut) ValueInBCH() float64

type TxHashCount

type TxHashCount struct {
	TxHash []byte
	Count  uint
}

func GetPostReplyCounts

func GetPostReplyCounts(txHashes [][]byte) ([]TxHashCount, error)

type TxOutSortByValue

type TxOutSortByValue []*TransactionOut

func (TxOutSortByValue) Len

func (txOuts TxOutSortByValue) Len() int

func (TxOutSortByValue) Less

func (txOuts TxOutSortByValue) Less(i, j int) bool

func (TxOutSortByValue) Swap

func (txOuts TxOutSortByValue) Swap(i, j int)

type User

type User struct {
	Id           uint   `gorm:"primary_key"`
	Username     string `gorm:"unique;size:50"`
	PasswordHash string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func CreateUser

func CreateUser(username string, hashedPassword string) (*User, error)

func GetUserById

func GetUserById(id uint) (*User, error)

func GetUserByUsername

func GetUserByUsername(username string) (*User, error)

func (*User) Delete

func (u *User) Delete() error

func (*User) Save

func (u *User) Save() error

type UserAction

type UserAction struct {
	Id                 uint `gorm:"primary_key"`
	UserId             uint
	LastNotificationId uint
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

type UserSettings

type UserSettings struct {
	Id           uint `gorm:"primary_key"`
	UserId       uint `gorm:"unique"`
	DefaultTip   uint
	Integrations string `gorm:"size:25"`
	Theme        string `gorm:"size:25"`
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func GetDefaultUserSettings

func GetDefaultUserSettings() UserSettings

func GetSettingsForUser

func GetSettingsForUser(userId uint) (*UserSettings, error)

func SaveSettingsForUser

func SaveSettingsForUser(userId uint, defaultTip uint, integrations string, theme string) (*UserSettings, error)

func (UserSettings) GetDefaultTipString

func (u UserSettings) GetDefaultTipString() string

func (*UserSettings) Save

func (u *UserSettings) Save() error

type UserStat

type UserStat struct {
	Id           uint   `gorm:"primary_key"`
	PkHash       []byte `gorm:"not null;unique"`
	NumPosts     int
	NumFollowers int
	FirstPost    time.Time
	LastPost     time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func AddUpdateStat

func AddUpdateStat(userStatObj view.UserStat) (*UserStat, error)

func GetUserStat

func GetUserStat(pkHash []byte) (*UserStat, error)

func (*UserStat) Save

func (u *UserStat) Save() error

type UserStatOrderType

type UserStatOrderType int
const (
	UserStatOrderCreated UserStatOrderType = iota
	UserStatOrderNewest
	UserStatOrderPosts
	UserStatOrderFollowers
)

type UserTopicView

type UserTopicView struct {
	Id         uint `gorm:"primary_key"`
	UserPkHash []byte
	Topic      string
	LastPostId uint
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetLastTopicPostIds

func GetLastTopicPostIds(userPkHash []byte, topics []string) ([]*UserTopicView, error)

type Value

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

func (Value) GetValue

func (v Value) GetValue() int64

func (Value) GetValueBCH

func (v Value) GetValueBCH() float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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