db

package
v0.0.0-...-d0dd730 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: Apache-2.0 Imports: 17 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

DB general DB struct

func CreateNewDB

func CreateNewDB(cnf *config.Config) (*DB, error)

CreateNewDB creates a new DB connection

func (DB) AddNewTransaction

func (db DB) AddNewTransaction(log *logrus.Entry, paymentChannel paymentchannel.Channel, txHash string,
	toAddress string, fromAddress string, order *m.UserOrder, denomAmount *big.Int, BTCOutIndex int) (isDuplicate bool, err error)

AddNewTransaction adds a transaction from the payment network to the database and returns true, if it was allready present The function implies, that the order is in status OrderStatusPaymentReceived

func (*DB) GetActiveExchangeCurrecnyByID

func (db *DB) GetActiveExchangeCurrecnyByID(exchangeID int, phaseID int, log *logrus.Entry) (*ExchangeCurrency, *m.IcoPhaseActivatedExchangeCurrency, error)

GetActiveExchangeCurrecnyByID returns the phase activated EC for the given id error if not activated

func (*DB) GetAllICOs

func (db *DB) GetAllICOs(log *logrus.Entry) (m.IcoSlice, error)

GetAllICOs returns a list of all ICOs

func (*DB) GetBitcoinBlockToProcess

func (db *DB) GetBitcoinBlockToProcess() (uint64, error)

GetBitcoinBlockToProcess saves the last processed btc block

func (*DB) GetEthereumBlockToProcess

func (db *DB) GetEthereumBlockToProcess() (uint64, error)

GetEthereumBlockToProcess gets the last processed eth block

func (*DB) GetExchangeCurrecnyByCode

func (db *DB) GetExchangeCurrecnyByCode(assetCode string, log *logrus.Entry) (*ExchangeCurrency, error)

GetExchangeCurrecnyByCode returns the EC for the given asset code

func (*DB) GetExchangeCurrecnyByID

func (db *DB) GetExchangeCurrecnyByID(id int, log *logrus.Entry) (*ExchangeCurrency, error)

GetExchangeCurrecnyByID returns the EC for the given id

func (*DB) GetICOByID

func (db *DB) GetICOByID(id int, log *logrus.Entry) (*m.Ico, error)

GetICOByID returns the given ICO by ID

func (*DB) GetICOPhaseByID

func (db *DB) GetICOPhaseByID(id int, log *logrus.Entry) (*m.IcoPhase, error)

GetICOPhaseByID returns the given ICOPhase by ID

func (*DB) GetOrderForAddress

func (db *DB) GetOrderForAddress(l paymentchannel.Channel, address string, paymentUsage string) (*m.UserOrder, error)

GetOrderForAddress reads the user orders for open payments for the specified address and chain If no open order was found(OrderStatusWaitingForPayment), the function will return either nil or filter for any other order with the given address The function will be called for EVERY payment transaction in the external PaymentNetworks paymentUsage is either an empty string or, for stellar, the MEMO with the orderID. If no memo/or wrong was given, the order will not be processed

func (*DB) GetStellarLedgerToProcess

func (db *DB) GetStellarLedgerToProcess() (int, error)

GetStellarLedgerToProcess returns the new ledgerid to process

func (*DB) PriceForCoins

func (db *DB) PriceForCoins(coins int64, ec *ExchangeCurrency, ph *m.IcoPhase) (denom *big.Int, nativAmount string, err error)

PriceForCoins returns the price for a given token-amount

func (*DB) SaveLastProcessedBitcoinBlock

func (db *DB) SaveLastProcessedBitcoinBlock(block uint64) error

SaveLastProcessedBitcoinBlock saves the last processed btc block

func (*DB) SaveLastProcessedEthereumBlock

func (db *DB) SaveLastProcessedEthereumBlock(block uint64) error

SaveLastProcessedEthereumBlock saves the last processed eth block

func (*DB) SaveLastProcessedStellarLedger

func (db *DB) SaveLastProcessedStellarLedger(ledgerID int) error

SaveLastProcessedStellarLedger saves the last processed stellar ledger

type ExchangeCurrency

type ExchangeCurrency struct {
	*m.ExchangeCurrency
	NativeCalculator
}

ExchangeCurrency is one ec

type ExchangeCurrencySlice

type ExchangeCurrencySlice []*ExchangeCurrency

ExchangeCurrencySlice list of ec's

type NativeCalculator

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

NativeCalculator calculates the native and denomination amounts

func NewNativeCalculator

func NewNativeCalculator(decimals int) NativeCalculator

NewNativeCalculator returns a new calculator that can be used in NativeCalculator

func (*NativeCalculator) DenomFromNativ

func (nc *NativeCalculator) DenomFromNativ(nativValue string) (*big.Int, error)

DenomFromNativ converts a given nativ (string)value (like eth,xlm,btc,euro) to its denomination The value can be in format 123.45 or 123,45 If the maximum number of accuracy is exceeded, an error is returned

func (*NativeCalculator) DenomFromString

func (nc *NativeCalculator) DenomFromString(denomValue string) (*big.Int, error)

DenomFromString returns the denominator as *big.Int for a given denominator string, e.g. 1234567

func (*NativeCalculator) ToNativ

func (nc *NativeCalculator) ToNativ(denom *big.Int) string

ToNativ converts a given denomination (like wei,sat, stroop, cent) to its nativ value

Jump to

Keyboard shortcuts

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