Documentation
¶
Index ¶
- Constants
- Variables
- func AddAccount(table string, ma *mgoAccount)
- func AddAddress(address, publicKey string)
- func AddBlock(table string, mb *mgoBlock)
- func AddDcrmAccount(table string, mda *mgoDcrmAccount)
- func AddDcrmAddress(address, cointype, dcrmAddress string, lockin, lockout int)
- func AddDexBlock(table string, mdb *mgoDexBlock)
- func AddDexTx(table string, mdt *mgoDexTx)
- func AddHistory(srcTx *types.Transaction)
- func AddOrder(table string, mo *mgoOrder) bool
- func AddOrderCache(table string, moc *mgoOrderCache, iu int)
- func AddTransaction(table string, mt *mgoTransaction)
- func CheckOrderCacheTxForODB(table, txHash string) bool
- func ClearDb(table string)
- func ConvertStringToFloat64(value string, cointype string) float64
- func Decode(s string) (interface{}, error)
- func DeleteBlock(table string, num uint64)
- func DeleteDcrmAccount(table, address, cointype string)
- func DeleteDexBlock(table string, Number uint64)
- func DeleteTransaction(table string, mt *mgoTransaction)
- func FindAccount(table, address string) []mgoAccount
- func FindBlock(table string, num uint64) []mgoBlock
- func FindDcrmAccount(table, initAddress, cointype string) []mgoDcrmAccount
- func FindDexBlock(table string, Number uint64, Trade string) []mgoDexBlock
- func FindDexTx(table, Hash string, Height uint64) []mgoDexTx
- func FindOrder(table string, hash string) []mgoOrder
- func FindOrderCache(table string, hash string) []mgoOrderCache
- func FindTransaction(table, Hash string) []mgoTransaction
- func FindTransactionToAccount(table string, address common.Address) []mgoTransaction
- func FindTransferHistory(table, key string) []mgoHistory
- func InsertOrderAndCache(msg string)
- func InsertOrderCache(hash, price, quantity, trade, side string)
- func IsDcrmLockOut(data []byte) bool
- func IsDexOrder(data []byte) bool
- func IsSyncedBlock(blockHash string) bool
- func LightSync(block *types.Block, txs []*types.Transaction)
- func MongoInit()
- func RemoveDexBlock(table string, mdb *mgoDexBlock)
- func RemoveDexTx(table string, mdt *mgoDexTx)
- func RemoveOrderCache(price, trade, side string)
- func RevSync(block *types.Block, receipts types.Receipts)
- func StartSync(path string)
- func Sync(block *types.Block, receipts types.Receipts, state *state.StateDB)
- func SyncGenesisAccount(address string, time uint64, balance string)
- func SyncGenesisBlock(block *types.Block)
- func UnCompress(s string) (string, error)
- func UpdataTransferHistoryStatus(tx *types.Transaction, reverse bool)
- func UpdataTransferHistoryStatus2(table, hash string, success bool)
- func UpdateAccount(ma *mgoAccount, value string, time uint64, add bool, fee string)
- func UpdateAccountPublicKey(table, address, pubkey string)
- func UpdateBalance(table, address, valueString string, value float64)
- func UpdateBalance4State(ma *mgoAccount, state *state.StateDB, time uint64)
- func UpdateComfirm(table, address string, value float64)
- func UpdateDcrmAccount(mda *mgoDcrmAccount, value string, time uint64, add bool, fee string, ...)
- func UpdateDcrmBalance(table, address, cointype, valueString string, value float64)
- func UpdateDcrmBalance4State(mda *mgoDcrmAccount, state *state.StateDB)
- func UpdateOrder(hash string, remain string)
- func UpdateOrderAddCache(tx *types.Transaction)
- func UpdateOrderCacheFromShare(msg interface{})
- func UpdateOrderFromShare(tx *types.Transaction)
- func UpdateOrderOrg(table string, mo *mgoOrder)
- func UpdateOrderStatus(hash string, status int)
- type BlockInfo
- type CurrentVolume
- type MatchRes
- type ODBInfo
- type OrderStatus
- type OrderTrade
- type SendMsg
- type XvcOrder
Constants ¶
View Source
const ( //ETH, ERC20BNB, ERC20GUSD, ERC20MKR, ERC20HT DIVE18 = float64(1000000000000000000) //BTC, BCH, USDT DIVE8 = float64(100000000) //TRX, XRP DIVE6 = float64(1000000) //EVT1 DIVE5 = float64(100000) //EOS DIVE4 = float64(10000) //ATOM DIVE3 = float64(1000) MUL1E9 = 1e9 MUL1E10 = 1e10 QuantityAccuracy int = 9 )
View Source
const ( SUCCESS = iota + 1 FAILURE EXIST = iota + 1 FINISHED INSERT = iota + 1 UPDATE )
Variables ¶
View Source
var ( Session *mgo.Session InitOnce bool )
View Source
var ( Mongo bool = false MongoSlave bool = false MongoIP string = "localhost" // default port: 27017 URL string MatchTrade string = "" )
View Source
var ( BlockLock sync.Mutex DexBlockLock sync.Mutex OrderCacheLock sync.Mutex OrderLock sync.Mutex DexTxnsLock sync.Mutex OrderAndCacheLock sync.Mutex ConfirmBlockNumber uint64 = 6 ConfirmBlockTime uint64 = 0 )
View Source
var LOGPRINTALL bool = false // true: print all log, false: do nothing
Functions ¶
func AddAccount ¶
func AddAccount(table string, ma *mgoAccount)
func AddAddress ¶
func AddAddress(address, publicKey string)
func AddDcrmAccount ¶
func AddDcrmAccount(table string, mda *mgoDcrmAccount)
func AddDcrmAddress ¶
func AddDexBlock ¶
func AddDexBlock(table string, mdb *mgoDexBlock)
func AddHistory ¶
func AddHistory(srcTx *types.Transaction)
func AddOrderCache ¶
func AddTransaction ¶
func AddTransaction(table string, mt *mgoTransaction)
func CheckOrderCacheTxForODB ¶
func ConvertStringToFloat64 ¶
func DeleteBlock ¶
func DeleteDcrmAccount ¶
func DeleteDcrmAccount(table, address, cointype string)
func DeleteDexBlock ¶
func DeleteDexBlock(table string, Number uint64, Trade string) {
func DeleteTransaction ¶
func DeleteTransaction(table string, mt *mgoTransaction)
func FindAccount ¶
func FindAccount(table, address string) []mgoAccount
func FindDcrmAccount ¶
func FindDcrmAccount(table, initAddress, cointype string) []mgoDcrmAccount
func FindDexBlock ¶
func FindOrderCache ¶
func FindTransaction ¶
func FindTransaction(table, Hash string) []mgoTransaction
func FindTransferHistory ¶
func FindTransferHistory(table, key string) []mgoHistory
func InsertOrderAndCache ¶
func InsertOrderAndCache(msg string)
call from InsertToOrderBook() xprotocol/exchange.go
func InsertOrderCache ¶
func InsertOrderCache(hash, price, quantity, trade, side string)
func IsDcrmLockOut ¶
func IsDexOrder ¶
func IsSyncedBlock ¶
func RemoveDexBlock ¶
func RemoveDexBlock(table string, mdb *mgoDexBlock)
func RemoveDexTx ¶
func RemoveDexTx(table string, mdt *mgoDexTx)
func RemoveOrderCache ¶
func RemoveOrderCache(price, trade, side string)
func SyncGenesisAccount ¶
func SyncGenesisBlock ¶
func UnCompress ¶
func UpdataTransferHistoryStatus ¶
func UpdataTransferHistoryStatus(tx *types.Transaction, reverse bool)
func UpdateAccount ¶
func UpdateAccountPublicKey ¶
func UpdateAccountPublicKey(table, address, pubkey string)
func UpdateBalance ¶
func UpdateBalance4State ¶
func UpdateComfirm ¶
func UpdateDcrmAccount ¶
func UpdateDcrmBalance ¶
func UpdateDcrmBalance4State ¶
func UpdateOrder ¶
func UpdateOrderAddCache ¶
func UpdateOrderAddCache(tx *types.Transaction)
func UpdateOrderCacheFromShare ¶
func UpdateOrderCacheFromShare(msg interface{})
func UpdateOrderFromShare ¶
func UpdateOrderFromShare(tx *types.Transaction)
func UpdateOrderOrg ¶
func UpdateOrderOrg(table string, mo *mgoOrder)
func UpdateOrderStatus ¶
func UpdateOrderCache(table string, hash string, quantity, price float64, v *orderbook.XvcOrder) { logPrintAll("==== UpdateOrderCache() ====", "hash", hash, "remain", quantity) orderCacheTimer := time.NewTimer(time.Duration(1) * time.Second) defer orderCacheTimer.Stop() oci, _ := orderCacheInfo.Load(hash) logPrintAll("==== UpdateOrderCache() ====", "hash", hash, "exist(1)/finish(2)", oci) count := 1 maxwait := 5 * 100 for { oci, _ := orderCacheInfo.Load(hash) if oci == EXIST { break } else if oci == FINISHED { collectionTable := getCollection(table) OrderCacheLock.Lock() collectionTable.Remove(bson.M{"_id": hash}) OrderCacheLock.Unlock() logPrintAll("==== UpdateOrderCache() ====", "remove: hash", hash, "remain", quantity) return } count++ if count > maxwait { logPrintAll("=== UpdateOrderCache() ====", "error not found orderCache hash", hash) break } <-orderCacheTimer.C orderCacheTimer.Reset(time.Duration(1) * time.Second) } collectionTable := getCollection(table) if quantity < (1 / DIVE8) { UpdateOrderStatus(hash, SUCCESS) OrderCacheLock.Lock() collectionTable.Remove(bson.M{"_id": hash}) OrderCacheLock.Unlock() logPrintAll("==== UpdateOrderCache() ====", "remove: hash", hash, "remain", quantity) orderCacheInfo.Store(hash, FINISHED) } else { total := price * quantity OrderCacheLock.Lock() collectionTable.Update(bson.M{"_id": hash}, bson.M{"$set": bson.M{ "volume": quantity, "total": total, }}) OrderCacheLock.Unlock() logPrintAll("==== UpdateOrderCache() ====", "update: hash", hash, "remain", quantity) } }
Types ¶
type CurrentVolume ¶
type MatchRes ¶
type MatchRes struct { Price string Done []*XvcOrder Volumes string Orders int CurVolume []*CurrentVolume }
func DecodeMatchRes ¶
func GetMrFromMatch ¶
type OrderStatus ¶
type OrderStatus struct {
ODS []OrderTrade
}
type OrderTrade ¶
Click to show internal directories.
Click to hide internal directories.