mongodb

package
v0.0.0-...-590ca12 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrItemNotFound              = newError(-32002, "mgoError: Item not found")
	ErrItemIsDup                 = newError(-32003, "mgoError: Item is duplicate")
	ErrSwapNotFound              = newError(-32011, "mgoError: Swap is not found")
	ErrSwapinTxNotStable         = newError(-32012, "mgoError: Swap in tx is not stable")
	ErrSwapinRecallExist         = newError(-32013, "mgoError: Swap in recall is exist")
	ErrSwapinRecalledOrForbidden = newError(-32014, "mgoError: Swap in is already recalled or can not recall")
)

mongodb special errors

Functions

func AddP2shAddress

func AddP2shAddress(ma *MgoP2shAddress) error

AddP2shAddress add p2sh address

func AddSwapin

func AddSwapin(ms *MgoSwap) error

AddSwapin add swapin

func AddSwapinResult

func AddSwapinResult(mr *MgoSwapResult) error

AddSwapinResult add swapin result

func AddSwapout

func AddSwapout(ms *MgoSwap) error

AddSwapout add swapout

func AddSwapoutResult

func AddSwapoutResult(mr *MgoSwapResult) error

AddSwapoutResult add swapout result

func FindP2shBindAddress

func FindP2shBindAddress(p2shAddress string) (string, error)

FindP2shBindAddress find bind address through p2sh address

func GetCountOfSwapinResults

func GetCountOfSwapinResults() (int, error)

GetCountOfSwapinResults get count of swapin results

func GetCountOfSwapinResultsWithStatus

func GetCountOfSwapinResultsWithStatus(status SwapStatus) (int, error)

GetCountOfSwapinResultsWithStatus get count of swapin results with status

func GetCountOfSwapinsWithStatus

func GetCountOfSwapinsWithStatus(status SwapStatus) (int, error)

GetCountOfSwapinsWithStatus get count of swapins with status

func GetCountOfSwapoutResults

func GetCountOfSwapoutResults() (int, error)

GetCountOfSwapoutResults get count of swapout results

func GetCountOfSwapoutResultsWithStatus

func GetCountOfSwapoutResultsWithStatus(status SwapStatus) (int, error)

GetCountOfSwapoutResultsWithStatus get count of swapout results with status

func GetCountOfSwapoutsWithStatus

func GetCountOfSwapoutsWithStatus(status SwapStatus) (int, error)

GetCountOfSwapoutsWithStatus get count of swapout with status

func InitCollections

func InitCollections()

InitCollections init some tables

func MongoServerInit

func MongoServerInit(mongourl, dbname string)

MongoServerInit int mongodb server session

func RecallSwapin

func RecallSwapin(txid string) error

RecallSwapin recall swapin

func UpdateLatestScanInfo

func UpdateLatestScanInfo(isSrc bool, blockHeight uint64) error

UpdateLatestScanInfo update latest scan info

func UpdateSwapStatistics

func UpdateSwapStatistics(value, swapValue string, isSwapin bool) error

UpdateSwapStatistics update swap statistics

func UpdateSwapinResult

func UpdateSwapinResult(txid string, items *SwapResultUpdateItems) error

UpdateSwapinResult update swapin result

func UpdateSwapinResultStatus

func UpdateSwapinResultStatus(txid string, status SwapStatus, timestamp int64, memo string) error

UpdateSwapinResultStatus update swapin result status

func UpdateSwapinStatus

func UpdateSwapinStatus(txid string, status SwapStatus, timestamp int64, memo string) error

UpdateSwapinStatus update swapin status

func UpdateSwapoutResult

func UpdateSwapoutResult(txid string, items *SwapResultUpdateItems) error

UpdateSwapoutResult update swapout result

func UpdateSwapoutResultStatus

func UpdateSwapoutResultStatus(txid string, status SwapStatus, timestamp int64, memo string) error

UpdateSwapoutResultStatus update swapout result status

func UpdateSwapoutStatus

func UpdateSwapoutStatus(txid string, status SwapStatus, timestamp int64, memo string) error

UpdateSwapoutStatus update swapout status

Types

type MgoLatestScanInfo

type MgoLatestScanInfo struct {
	Key         string `bson:"_id"`
	BlockHeight uint64 `bson:"blockheight"`
	Timestamp   int64  `bson:"timestamp"`
}

MgoLatestScanInfo latest scan info

func FindLatestScanInfo

func FindLatestScanInfo(isSrc bool) (*MgoLatestScanInfo, error)

FindLatestScanInfo find latest scan info

type MgoP2shAddress

type MgoP2shAddress struct {
	Key         string `bson:"_id"`
	P2shAddress string `bson:"p2shaddress"`
}

MgoP2shAddress key is the bind address

func FindP2shAddress

func FindP2shAddress(key string) (*MgoP2shAddress, error)

FindP2shAddress find p2sh addrss through bind address

func FindP2shAddresses

func FindP2shAddresses(offset, limit int) ([]*MgoP2shAddress, error)

FindP2shAddresses find p2sh address

type MgoSwap

type MgoSwap struct {
	Key       string     `bson:"_id"`
	TxID      string     `bson:"txid"`
	TxType    uint32     `bson:"txtype"`
	Bind      string     `bson:"bind"`
	Status    SwapStatus `bson:"status"`
	Timestamp int64      `bson:"timestamp"`
	Memo      string     `bson:"memo"`
}

MgoSwap registered swap

func FindSwapin

func FindSwapin(txid string) (*MgoSwap, error)

FindSwapin find swapin

func FindSwapinsWithStatus

func FindSwapinsWithStatus(status SwapStatus, septime int64) ([]*MgoSwap, error)

FindSwapinsWithStatus find swapin with status in the past septime

func FindSwapout

func FindSwapout(txid string) (*MgoSwap, error)

FindSwapout find swapout

func FindSwapoutsWithStatus

func FindSwapoutsWithStatus(status SwapStatus, septime int64) ([]*MgoSwap, error)

FindSwapoutsWithStatus find swapout with status

type MgoSwapResult

type MgoSwapResult struct {
	Key        string     `bson:"_id"`
	TxID       string     `bson:"txid"`
	TxHeight   uint64     `bson:"txheight"`
	TxTime     uint64     `bson:"txtime"`
	From       string     `bson:"from"`
	To         string     `bson:"to"`
	Bind       string     `bson:"bind"`
	Value      string     `bson:"value"`
	SwapTx     string     `bson:"swaptx"`
	SwapHeight uint64     `bson:"swapheight"`
	SwapTime   uint64     `bson:"swaptime"`
	SwapValue  string     `bson:"swapvalue"`
	SwapType   uint32     `bson:"swaptype"`
	Status     SwapStatus `bson:"status"`
	Timestamp  int64      `bson:"timestamp"`
	Memo       string     `bson:"memo"`
}

MgoSwapResult swap result (verified swap)

func FindSwapinResult

func FindSwapinResult(txid string) (*MgoSwapResult, error)

FindSwapinResult find swapin result

func FindSwapinResults

func FindSwapinResults(address string, offset, limit int) ([]*MgoSwapResult, error)

FindSwapinResults find swapin history results

func FindSwapinResultsWithStatus

func FindSwapinResultsWithStatus(status SwapStatus, septime int64) ([]*MgoSwapResult, error)

FindSwapinResultsWithStatus find swapin result with status

func FindSwapoutResult

func FindSwapoutResult(txid string) (*MgoSwapResult, error)

FindSwapoutResult find swapout result

func FindSwapoutResults

func FindSwapoutResults(address string, offset, limit int) ([]*MgoSwapResult, error)

FindSwapoutResults find swapout history results

func FindSwapoutResultsWithStatus

func FindSwapoutResultsWithStatus(status SwapStatus, septime int64) ([]*MgoSwapResult, error)

FindSwapoutResultsWithStatus find swapout result with status

type MgoSwapStatistics

type MgoSwapStatistics struct {
	Key                string `bson:"_id"`
	StableSwapinCount  int    `bson:"swapincount"`
	TotalSwapinValue   string `bson:"totalswapinvalue"`
	TotalSwapinFee     string `bson:"totalswapinfee"`
	StableSwapoutCount int    `bson:"swapoutcount"`
	TotalSwapoutValue  string `bson:"totalswapoutvalue"`
	TotalSwapoutFee    string `bson:"totalswapoutfee"`
}

MgoSwapStatistics swap statistics

func FindSwapStatistics

func FindSwapStatistics() (*MgoSwapStatistics, error)

FindSwapStatistics find swap statistics

type SwapResultUpdateItems

type SwapResultUpdateItems struct {
	SwapTx     string
	SwapHeight uint64
	SwapTime   uint64
	SwapValue  string
	SwapType   uint32
	Status     SwapStatus
	Timestamp  int64
	Memo       string
}

SwapResultUpdateItems swap update items

type SwapStatistics

type SwapStatistics struct {
	TotalSwapinCount    int
	TotalSwapoutCount   int
	PendingSwapinCount  int
	PendingSwapoutCount int
	StableSwapinCount   int
	TotalSwapinValue    string
	TotalSwapinFee      string
	StableSwapoutCount  int
	TotalSwapoutValue   string
	TotalSwapoutFee     string
}

SwapStatistics rpc return struct

func GetSwapStatistics

func GetSwapStatistics() (*SwapStatistics, error)

GetSwapStatistics get swap statistics

type SwapStatus

type SwapStatus uint16

SwapStatus swap status

const (
	TxNotStable      SwapStatus = iota // 0
	TxVerifyFailed                     // 1
	TxCanRecall                        // 2
	TxToBeRecall                       // 3
	TxRecallFailed                     // 4
	TxNotSwapped                       // 5
	TxSwapFailed                       // 6
	TxProcessed                        // 7
	MatchTxEmpty                       // 8
	MatchTxNotStable                   // 9
	MatchTxStable                      // 10
	TxWithWrongMemo                    // 11
)

swap status values

func (SwapStatus) String

func (status SwapStatus) String() string

Jump to

Keyboard shortcuts

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