models

package
v0.0.0-...-8556144 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AddrCollectionName = "address"
View Source
const BlockCollectionName = "blocks"
View Source
const TransactionCollectionName = "txns"

Variables

This section is empty.

Functions

func IsAddressPresent

func IsAddressPresent(b *Address) (bool, error)

func IsBlockPresent

func IsBlockPresent(blockHash string) (bool, error)

IsBlockPresent checks if the block with the hash provided is present or not

func StoreAddress

func StoreAddress(b *Address) error

func StoreAddressIfNotPresent

func StoreAddressIfNotPresent(b *Address) error

func StoreBlock

func StoreBlock(b *Block) error

func StoreTransaction

func StoreTransaction(txn *Transaction) error

Types

type Address

type Address struct {
	Addr     string `json:"address" bson:"address"`
	Sent     int
	Received int
	Balance  int
}

type Block

type Block struct {
	Hash              string  `bson:"hash" json:"hash"`
	Confirmations     uint    `bson:"confirmation" json:"confirmation"`
	Size              uint    `bson:"size" json:"size"`
	Height            uint    `bson:"height" json:"height"`
	Version           uint    `bson:"version" json:"version"`
	MerkeleRoot       string  `bson:"merkeleroot" json:"merkeleroot"`
	Mint              float64 `bson:"mint" json:"mint"`
	Time              uint    `bson:"time" json:"time"`
	Difficulty        float64 `bson:"difficulty" json:"difficulty"`
	Blocktrust        string  `bson:"blocktrust" json:"blocktrust"`
	Chaintrust        string  `bson:"chaintrust" json:"chaintrust"`
	Nextblockhash     string  `bson:"nextblockhash" json:"nextblockhash"`
	Previousblockhash string  `bson:"previousblockhash" json:"previousblockhash"`
	EntropyBit        int     `bson:"entropybit" json:"entropybit"`
	Modifier          string  `bson:"modifier" json:"modifier"`
	Modifierchecksum  string  `bson:"modifierchecksum" json:"modifierchecksum"`
	Signature         string  `bson:"signature" json:"signature"`
}

type Transaction

type Transaction struct {
	TxID       string `json:"txid" bson:"txid"`
	Blockhash  string `json:"blockhash" bson:"blockhash"`
	Blockindex uint   `json:"blockindex" bson:"blockindex"`
	Timestamp  uint   `json:"timestamp" bson:"timestamp"`
	Total      uint   `json:"total" bson:"total"`
	Vout       []*V   `json:"vout" bson:"vout"`
	Vin        []*V   `json:"vin" bson:"vin"`
}

type User

type User struct {
	ID               bson.ObjectId   `bson:"_id" json:"-"`
	PurseHash        string          `bson:"purseHash" json:"purseHash"`
	Token            string          `bson:"token" json:"token"`
	HasAutoUpdate    bool            `bson:"hasAutoUpdate" json:"hasAutoUpdate"`
	IsSynchronized   bool            `bson:"isSynchronized" json:"isSynchronized"`
	PursePrivateKey  string          `bson:"pursePrivateKey" json:"-"`
	TwitterUsername  string          `bson:"twitterUsername" json:"twitterUsername"`
	TwitterCheckedAt time.Time       `bson:"twitterCheckedAt" json:"twitterCheckedAt"`
	BootstrapNodes   []bson.ObjectId `bson:"bootstrapNodes" json:"-"`
	CreatedAt        time.Time       `bson:"createdAt" json:"createdAt"`
	UpdatedAt        time.Time       `bson:"updatedAt" json:"updatedAt"`
}

User model.

func (User) GetByPurseHash

func (u User) GetByPurseHash(purseHash string) (*User, error)

GetByPurseHash gets a user from the database by their Purse Account address hash.

func (User) Insert

func (u User) Insert(purseHash string) (*User, error)

Insert creates a new user in the database.

func (User) Update

func (u User) Update(purseHash string, data UserEditable) (*User, error)

Update the data of an exising user in the database.

func (User) UpdatePursePrivateKey

func (u User) UpdatePursePrivateKey(
	purseHash string,
	pursePrivateKey string,
) (*User, error)

UpdatePursePrivateKey for the user owning this purse address.

type UserEditable

type UserEditable struct {
	HasAutoUpdate   bool   `bson:"hasAutoUpdate" json:"hasAutoUpdate"`
	IsSynchronized  bool   `bson:"isSynchronized" json:"isSynchronized"`
	TwitterUsername string `bson:"twitterUsername" json:"twitterUsername"`
}

UserEditable model.

type UserToken

type UserToken struct {
	ID        bson.ObjectId `bson:"_id" json:"-"`
	Challenge string        `bson:"challenge" json:"challenge"`
	PurseHash string        `bson:"purseHash" json:"purseHash"`
	CreatedAt time.Time     `bson:"createdAt" json:"createdAt"`
	UpdatedAt time.Time     `bson:"updatedAt" json:"updatedAt"`
}

UserToken model.

func (UserToken) GetByPurseHash

func (u UserToken) GetByPurseHash(purseHash string) (*UserToken, error)

GetByPurseHash finds a user token in the database by its Purse Account address hash.

func (UserToken) Insert

func (u UserToken) Insert(purseHash string) (*UserToken, error)

Insert generates and creates a new user token in the database.

type V

type V struct {
	Address string `json:"addresses" bson:"addresses"`
	Amount  uint   `json:"amount" bson:"amount"`
}

Jump to

Keyboard shortcuts

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