mongodb

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: GPL-3.0, LGPL-3.0, LGPL-3.0-or-later Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyOfLatestSyncInfo string = "latest"
)

Variables

This section is empty.

Functions

func AddBlock

func AddBlock(mb *MgoBlock, overwrite bool) (err error)

func AddContract

func AddContract(mc *MgoContract) error

func AddSyncInfo

func AddSyncInfo(msi *MgoSyncInfo) error

func AddTransaction

func AddTransaction(mt *MgoTransaction, overwrite bool) error

func DeleteBlock

func DeleteBlock(hash string) error

func DeleteLatestSyncInfo

func DeleteLatestSyncInfo() error

func DeleteTransaction

func DeleteTransaction(hash string) error

func Fsync

func Fsync(async bool) error

Fsync flush memory to db

func InitLatestSyncInfo

func InitLatestSyncInfo() error

func MongoServerInit

func MongoServerInit(addrs []string, dbname, user, pass string)

MongoServerInit int mongodb server session

func UpdateBlockInfo

func UpdateBlockInfo(key string, blocktime, td uint64) error

func UpdateSyncInfo

func UpdateSyncInfo(num, timestamp, td uint64) error

Types

type Erc20Receipt

type Erc20Receipt struct {
	LogType  string `bson:"logType"`
	LogIndex int    `bson:"logIndex"`
	Erc20    string `bson:"erc20"`
	From     string `bson:"from"`
	To       string `bson:"to"`
	Value    string `bson:"value"`
}

Erc20Receipt erc20 tx receipt

type ExchangeReceipt

type ExchangeReceipt struct {
	LogType         string `bson:"txnsType"`
	LogIndex        int    `bson:"logIndex"`
	Exchange        string `bson:"exchange"`
	Address         string `bson:"address"`
	TokenFromAmount string `bson:"tokenFromAmount"`
	TokenToAmount   string `bson:"tokenToAmount"`
}

ExchangeReceipt exchange tx receipt

type MgoBlock

type MgoBlock struct {
	Key             string   `bson:"_id"`
	Number          uint64   `bson:"number"`
	Hash            string   `bson:"hash"`
	ParentHash      string   `bson:"parentHash"`
	Nonce           uint64   `bson:"ticketOrder"` // spec
	Miner           string   `bson:"miner"`
	Difficulty      uint64   `bson:"difficulty"`
	TotalDifficulty uint64   `bson:"totalDifficulty"`
	Size            uint64   `bson:"size"`
	GasLimit        uint64   `bson:"gasLimit"`
	GasUsed         uint64   `bson:"gasUsed"`
	Timestamp       uint64   `bson:"timestamp"`
	BlockTime       uint64   `bson:"blockTime"`
	TxCount         int      `bson:"txcount"`
	AvgGasprice     string   `bson:"avgGasprice"`
	Reward          string   `bson:"reward"`
	SelectedTicket  string   `bson:"selectedTicket"` // spec
	RetreatTickets  []string `bson:"retreatTickets"` // spec
	RetreatMiners   []string `bson:"retreatMiners"`  // spec
	TicketNumber    int      `bson:"ticketNumber"`   // spec
}

func FindBlock

func FindBlock(hash string) (*MgoBlock, error)

func FindBlockByNumber

func FindBlockByNumber(num uint64) (*MgoBlock, error)

func FindBlocksInRange

func FindBlocksInRange(start, end uint64) ([]*MgoBlock, error)

type MgoContract

type MgoContract struct {
	Key  string `bson:"_id"`
	Type string `bson:"type"` // ERC20, MBTC, ...
}

func FindContract

func FindContract(address string) (*MgoContract, error)

type MgoSyncInfo

type MgoSyncInfo struct {
	Key             string `bson:"_id"`
	Number          uint64 `bson:"number"`
	Timestamp       uint64 `bson:"timestamp"`
	TotalDifficulty uint64 `bson:"totalDifficulty"`
}

func FindLatestSyncInfo

func FindLatestSyncInfo() (*MgoSyncInfo, error)

type MgoTransaction

type MgoTransaction struct {
	Key              string      `bson:"_id"`
	Hash             string      `bson:"hash"`
	Nonce            uint64      `bson:"nonce"`
	BlockHash        string      `bson:"blockHash"`
	BlockNumber      uint64      `bson:"blockNumber"`
	TransactionIndex int         `bson:"transactionIndex"`
	From             string      `bson:"from"`
	To               string      `bson:"to"`
	Value            string      `bson:"value"`
	ValueInt         uint64      `bson:"ivalue"`
	ValueDec         uint64      `bson:"dvalue"`
	GasLimit         uint64      `bson:"gasLimit"`
	GasPrice         string      `bson:"gasPrice"`
	GasUsed          uint64      `bson:"gasUsed"`
	Timestamp        uint64      `bson:"timestamp"`
	Input            string      `bson:"input"`
	Status           uint64      `bson:"status"`
	CoinType         string      `bson:"coinType"`
	Type             string      `bson:"type"` // spec
	Log              interface{} `bson:"log"`  // spec

	Erc20Receipts    []*Erc20Receipt    `bson:"erc20Receipts,omitempty"`
	ExchangeReceipts []*ExchangeReceipt `bson:"exchangeReceipts,omitempty"`
}

func FindTransaction

func FindTransaction(hash string) (*MgoTransaction, error)

Jump to

Keyboard shortcuts

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