Documentation ¶
Index ¶
- Variables
- func AddRouterSwap(ms *MgoSwap) error
- func AddRouterSwapResult(mr *MgoSwapResult) error
- func AddUsedRValue(pubkey, r string) error
- func ConvertFromSwapInfo(swapinfo *SwapInfo) (tokens.SwapInfo, error)
- func FindNextSwapNonce(chainID, mpc string) (uint64, error)
- func HasSession() bool
- func MongoServerInit(addrs []string, dbname, user, pass string)
- func RouterAdminPassBigValue(fromChainID, txid string, logIndex int) error
- func RouterAdminReswap(fromChainID, txid string, logIndex int) error
- func UpdateRouterSwapResult(fromChainID, txid string, logindex int, items *SwapResultUpdateItems) error
- func UpdateRouterSwapResultStatus(fromChainID, txid string, logindex int, status SwapStatus, timestamp int64, ...) error
- func UpdateRouterSwapStatus(fromChainID, txid string, logindex int, status SwapStatus, timestamp int64, ...) error
- type AnyCallSwapInfo
- type MgoSwap
- type MgoSwapResult
- func FindRouterSwapResult(fromChainID, txid string, logindex int) (*MgoSwapResult, error)
- func FindRouterSwapResults(fromChainID, address string, offset, limit int, status string) ([]*MgoSwapResult, error)
- func FindRouterSwapResultsToReplace(septime int64) ([]*MgoSwapResult, error)
- func FindRouterSwapResultsWithChainIDAndStatus(fromChainID string, status SwapStatus, septime int64) ([]*MgoSwapResult, error)
- func FindRouterSwapResultsWithStatus(status SwapStatus, septime int64) ([]*MgoSwapResult, error)
- type MgoUsedRValue
- type RouterSwapInfo
- type SwapInfo
- type SwapResultUpdateItems
- type SwapStatus
Constants ¶
This section is empty.
Variables ¶
var ( ErrItemNotFound = newError(-32002, "mgoError: Item not found") ErrItemIsDup = newError(-32003, "mgoError: Item is duplicate") ErrSwapNotFound = newError(-32011, "mgoError: Swap is not found") ErrWrongKey = newError(-32012, "mgoError: Wrong key") ErrForbidUpdateNonce = newError(-32013, "mgoError: Forbid update swap nonce") ErrForbidUpdateSwapTx = newError(-32014, "mgoError: Forbid update swap tx") )
mongodb special errors
var ( // MgoWaitGroup wait all mongodb related task done MgoWaitGroup = new(sync.WaitGroup) )
Functions ¶
func AddRouterSwapResult ¶
func AddRouterSwapResult(mr *MgoSwapResult) error
AddRouterSwapResult add router swap result
func AddUsedRValue ¶ added in v3.2.0
AddUsedRValue add used r, if error mean already exist
func ConvertFromSwapInfo ¶
ConvertFromSwapInfo convert
func FindNextSwapNonce ¶
FindNextSwapNonce find next swap nonce
func MongoServerInit ¶
MongoServerInit int mongodb server session
func RouterAdminPassBigValue ¶
RouterAdminPassBigValue pass big value
func RouterAdminReswap ¶
RouterAdminReswap reswap
func UpdateRouterSwapResult ¶
func UpdateRouterSwapResult(fromChainID, txid string, logindex int, items *SwapResultUpdateItems) error
UpdateRouterSwapResult update router swap result
func UpdateRouterSwapResultStatus ¶
func UpdateRouterSwapResultStatus(fromChainID, txid string, logindex int, status SwapStatus, timestamp int64, memo string) error
UpdateRouterSwapResultStatus update router swap result status
func UpdateRouterSwapStatus ¶
func UpdateRouterSwapStatus(fromChainID, txid string, logindex int, status SwapStatus, timestamp int64, memo string) error
UpdateRouterSwapStatus update router swap status
Types ¶
type AnyCallSwapInfo ¶
type AnyCallSwapInfo struct { CallFrom string `bson:"callFrom" json:"callFrom"` CallTo []string `bson:"callTo" json:"callTo"` CallData []string `bson:"callData" json:"callData"` Callbacks []string `bson:"callbacks" json:"callbacks"` CallNonces []string `bson:"callNonces" json:"callNonces"` }
AnyCallSwapInfo struct
type MgoSwap ¶
type MgoSwap struct { Key string `bson:"_id"` // fromChainID + txid + logindex SwapType uint32 `bson:"swaptype"` TxID string `bson:"txid"` TxTo string `bson:"txto"` Bind string `bson:"bind"` LogIndex int `bson:"logIndex"` FromChainID string `bson:"fromChainID"` ToChainID string `bson:"toChainID"` SwapInfo `bson:"swapinfo"` Status SwapStatus `bson:"status"` InitTime int64 `bson:"inittime"` Timestamp int64 `bson:"timestamp"` Memo string `bson:"memo"` }
MgoSwap registered swap
func FindRouterSwap ¶
FindRouterSwap find router swap
func FindRouterSwapsWithChainIDAndStatus ¶
func FindRouterSwapsWithChainIDAndStatus(fromChainID string, status SwapStatus, septime int64) ([]*MgoSwap, error)
FindRouterSwapsWithChainIDAndStatus find router swap with chainid and status in the past septime
func FindRouterSwapsWithStatus ¶
func FindRouterSwapsWithStatus(status SwapStatus, septime int64) ([]*MgoSwap, error)
FindRouterSwapsWithStatus find router swap with status
type MgoSwapResult ¶
type MgoSwapResult struct { Key string `bson:"_id"` // fromChainID + txid + logindex SwapType uint32 `bson:"swaptype"` TxID string `bson:"txid"` TxTo string `bson:"txto"` TxHeight uint64 `bson:"txheight"` TxTime uint64 `bson:"txtime"` From string `bson:"from"` To string `bson:"to"` Bind string `bson:"bind"` Value string `bson:"value"` LogIndex int `bson:"logIndex"` FromChainID string `bson:"fromChainID"` ToChainID string `bson:"toChainID"` SwapInfo `bson:"swapinfo"` SwapTx string `bson:"swaptx"` OldSwapTxs []string `bson:"oldswaptxs"` SwapHeight uint64 `bson:"swapheight"` SwapTime uint64 `bson:"swaptime"` SwapValue string `bson:"swapvalue"` SwapNonce uint64 `bson:"swapnonce"` Status SwapStatus `bson:"status"` InitTime int64 `bson:"inittime"` Timestamp int64 `bson:"timestamp"` Memo string `bson:"memo"` MPC string `bson:"mpc"` }
MgoSwapResult swap result (verified swap)
func FindRouterSwapResult ¶
func FindRouterSwapResult(fromChainID, txid string, logindex int) (*MgoSwapResult, error)
FindRouterSwapResult find router swap result
func FindRouterSwapResults ¶
func FindRouterSwapResults(fromChainID, address string, offset, limit int, status string) ([]*MgoSwapResult, error)
FindRouterSwapResults find router swap results with chainid and address
func FindRouterSwapResultsToReplace ¶
func FindRouterSwapResultsToReplace(septime int64) ([]*MgoSwapResult, error)
FindRouterSwapResultsToReplace find router swap result with status
func FindRouterSwapResultsWithChainIDAndStatus ¶
func FindRouterSwapResultsWithChainIDAndStatus(fromChainID string, status SwapStatus, septime int64) ([]*MgoSwapResult, error)
FindRouterSwapResultsWithChainIDAndStatus find router swap result with chainid and status in the past septime
func FindRouterSwapResultsWithStatus ¶
func FindRouterSwapResultsWithStatus(status SwapStatus, septime int64) ([]*MgoSwapResult, error)
FindRouterSwapResultsWithStatus find router swap result with status
type MgoUsedRValue ¶ added in v3.2.0
type MgoUsedRValue struct { Key string `bson:"_id"` // r + pubkey Timestamp int64 `bson:"timestamp"` }
MgoUsedRValue security enhancement
type RouterSwapInfo ¶
type RouterSwapInfo struct { ForNative bool `bson:"forNative,omitempty" json:"forNative,omitempty"` ForUnderlying bool `bson:"forUnderlying,omitempty" json:"forUnderlying,omitempty"` Token string `bson:"token" json:"token"` TokenID string `bson:"tokenID" json:"tokenID"` Path []string `bson:"path,omitempty" json:"path,omitempty"` AmountOutMin string `bson:"amountOutMin,omitempty" json:"amountOutMin,omitempty"` }
RouterSwapInfo struct
type SwapInfo ¶
type SwapInfo struct { *RouterSwapInfo `bson:"routerSwapInfo,omitempty" json:"routerSwapInfo,omitempty"` *AnyCallSwapInfo `bson:"anycallSwapInfo,omitempty" json:"anycallSwapInfo,omitempty"` }
SwapInfo struct
func ConvertToSwapInfo ¶
ConvertToSwapInfo convert
type SwapResultUpdateItems ¶
type SwapResultUpdateItems struct { MPC string SwapTx string OldSwapTxs []string SwapHeight uint64 SwapTime uint64 SwapValue string SwapNonce uint64 Status SwapStatus Timestamp int64 Memo string }
SwapResultUpdateItems swap update items
type SwapStatus ¶
type SwapStatus uint16
SwapStatus swap status
const ( TxNotStable SwapStatus = iota // 0 TxVerifyFailed // 1 TxWithWrongSender // 2 TxWithWrongValue // 3 TxIncompatible // 4 TxNotSwapped // 5 TxSwapFailed // 6 TxProcessed // 7 MatchTxEmpty // 8 MatchTxNotStable // 9 MatchTxStable // 10 TxWithWrongMemo // 11 TxWithBigValue // 12 TxSenderNotRegistered // 13 MatchTxFailed // 14 SwapInBlacklist // 15 ManualMakeFail // 16 BindAddrIsContract // 17 RPCQueryError // 18 TxWithWrongPath // 19 MissTokenConfig // 20 NoUnderlyingToken // 21 KeepStatus = 255 Reswapping = 256 )
swap status values
func GetRouterSwapStatusByVerifyError ¶
func GetRouterSwapStatusByVerifyError(err error) SwapStatus
GetRouterSwapStatusByVerifyError get router swap status by verify error
func (SwapStatus) IsRegisteredOk ¶
func (status SwapStatus) IsRegisteredOk() bool
IsRegisteredOk is successfully registered
func (SwapStatus) String ¶
func (status SwapStatus) String() string
nolint:gocyclo // allow big simple switch