transactions

package
v0.0.0-...-eed2fd3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltStore

type BoltStore struct {
	DatabaseFile string
	// contains filtered or unexported fields
}

BoltStore implements the IStore and uses BoltDB for storage of transactions

func NewBoltStore

func NewBoltStore(path string) (*BoltStore, error)

NewBoltStore creates a new store object

func (*BoltStore) AddTransaction

func (s *BoltStore) AddTransaction(t *Transaction) error

AddTransaction adds a transaction to the bolt database

func (*BoltStore) DeleteTransaction

func (s *BoltStore) DeleteTransaction(t *Transaction) error

DeleteTransaction deletes a transaction from the bolt database

func (*BoltStore) GetTransactions

func (s *BoltStore) GetTransactions() ([]*Transaction, error)

GetTransactions returns all transactions from the bolt database

func (*BoltStore) GetTransactionsTemp

func (s *BoltStore) GetTransactionsTemp() ([]*Transaction, error)

GetTransactionsTemp will replace GetTransactions when bolt implementation is done

func (*BoltStore) Start

func (s *BoltStore) Start() error

Start loads the database of exist if not it will create a database

func (*BoltStore) Stop

func (s *BoltStore) Stop()

Stop stops the database

func (*BoltStore) UpdateTransaction

func (s *BoltStore) UpdateTransaction(t *Transaction) error

UpdateTransaction updates a transaction in the database

type IStore

type IStore interface {
	Start() error
	Stop()
	GetTransactions() ([]*Transaction, error)
	AddTransaction(t *Transaction) error
	UpdateTransaction(t *Transaction) error
	DeleteTransaction(t *Transaction) error
}

IStore defines the operations a store must implement

type Transaction

type Transaction struct {
	ID         int             `json:"id"`
	Type       TransactionType `json:"type"`
	CoinID     string          `json:"coinId"`
	CoinAmount float64         `json:"coinAmount"`
	DateTime   int64           `json:"dateTime"`
	PriceUSD   float64         `json:"priceUsd"`
	Hide       bool            `json:"hide"`
}

Transaction describes a but or sell transaction

type TransactionType

type TransactionType int

TransactionType is the type of transaction: buy or sell

const (
	TransactionBuy TransactionType = iota
	TransactionSell
)

TransactionType enumeration

Jump to

Keyboard shortcuts

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