txmanager

package
v0.0.0-...-491e088 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: Apache-2.0 Imports: 16 Imported by: 9

Documentation

Index

Constants

View Source
const (
	FillOwnerPrefix = "txm_fill_owner_"
	FillOwnerTtl    = 600           // todo 临时数据,只存储10分钟,系统性宕机后无法重启后丢失?
	TxEntityPrefix  = "txm_entity_" // txm_entity_blocknumber_txhash_logIndex,不用hash结构,避免不同用户数据在同一个key的情况
	TxEntityTtl     = 86400
)

Variables

View Source
var (
	ErrOwnerAddressInvalid error = errors.New("owner address invalid")
	ErrHashListEmpty       error = errors.New("hash list is empty")
	ErrNonTransaction      error = errors.New("no transaction found")
)

Functions

func ExistFillOwnerCache

func ExistFillOwnerCache(txhash common.Hash, owner common.Address) (bool, error)

func GetAllTransactionCount

func GetAllTransactionCount(ownerStr, symbol, status, typ string) (int, error)

func GetAllTransactions

func GetAllTransactions(owner, symbol, status, typ string, limit, offset int) ([]txtyp.TransactionJsonResult, error)

func GetPendingTransactions

func GetPendingTransactions(owner string) ([]txtyp.TransactionJsonResult, error)

func GetTransactionsByHash

func GetTransactionsByHash(owner string, hashList []string) ([]txtyp.TransactionJsonResult, error)

func NewTxView

func NewTxView(db dao.RdsService)

todo(fuk): 在分布式锁以及wallet_service事件通知推送落地后使用redis缓存(当前版本暂时不考虑redis),考虑到分叉及用户tx总量, 缓存应该有三个数据类型: 1. user key 存储用户pengding&mined first page transactions,设置过期时间 2. user tx number key存储某个用户所有tx数量的key,设置过期时间 3. block key 存储某个block涉及到的用户key(用于分叉),设置过期时间

func RollbackCache

func RollbackCache(from, to int64) error

func SaveEntityCache

func SaveEntityCache(entity dao.TransactionEntity) error

func SetFillOwnerCache

func SetFillOwnerCache(txhash common.Hash, owner common.Address) error

Types

type TransactionEntityMap

type TransactionEntityMap map[string]map[int64]dao.TransactionEntity

func GetEntityCache

func GetEntityCache(db dao.RdsService, views []dao.TransactionView) TransactionEntityMap

GetEntityCache return map[hash][logindex]dao.transactionEntity todo get multi key from redis with lua

type TransactionManager

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

func NewTxManager

func NewTxManager(db dao.RdsService, accountmanager *market.AccountManager) TransactionManager

func (*TransactionManager) ForkProcess

func (tm *TransactionManager) ForkProcess(input eventemitter.EventData) error

todo: check and test

func (*TransactionManager) SaveApproveEvent

func (tm *TransactionManager) SaveApproveEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveCutoffAllEvent

func (tm *TransactionManager) SaveCutoffAllEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveCutoffPairEvent

func (tm *TransactionManager) SaveCutoffPairEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveEthTransferEvent

func (tm *TransactionManager) SaveEthTransferEvent(input eventemitter.EventData) error

普通的transaction 当value大于0时认为是eth转账 当value等于0时认为是调用系统不支持的合约,默认使用fromTransferEvent/send type为unsupported_contract

func (*TransactionManager) SaveOrderCancelledEvent

func (tm *TransactionManager) SaveOrderCancelledEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveOrderFilledEvent

func (tm *TransactionManager) SaveOrderFilledEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveTransferEvent

func (tm *TransactionManager) SaveTransferEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveWethDepositEvent

func (tm *TransactionManager) SaveWethDepositEvent(input eventemitter.EventData) error

func (*TransactionManager) SaveWethWithdrawalEvent

func (tm *TransactionManager) SaveWethWithdrawalEvent(input eventemitter.EventData) error

func (*TransactionManager) Start

func (tm *TransactionManager) Start()

Start start orderbook as a service

func (*TransactionManager) Stop

func (tm *TransactionManager) Stop()

type TransactionViewer

type TransactionViewer interface {
	GetPendingTransactions(owner string) ([]txtyp.TransactionJsonResult, error)
	GetAllTransactionCount(owner, symbol, status, typ string) (int, error)
	GetAllTransactions(owner, symbol, status, typ string, limit, offset int) ([]txtyp.TransactionJsonResult, error)
	GetTransactionsByHash(owner string, hashList []string) ([]txtyp.TransactionJsonResult, error)
}

type TransactionViewerImpl

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

func (*TransactionViewerImpl) GetAllTransactionCount

func (impl *TransactionViewerImpl) GetAllTransactionCount(ownerStr, symbolStr, statusStr, typStr string) (int, error)

func (*TransactionViewerImpl) GetAllTransactions

func (impl *TransactionViewerImpl) GetAllTransactions(ownerStr, symbolStr, statusStr, typStr string, limit, offset int) ([]txtyp.TransactionJsonResult, error)

func (*TransactionViewerImpl) GetPendingTransactions

func (impl *TransactionViewerImpl) GetPendingTransactions(ownerStr string) ([]txtyp.TransactionJsonResult, error)

func (*TransactionViewerImpl) GetTransactionsByHash

func (impl *TransactionViewerImpl) GetTransactionsByHash(ownerStr string, hashList []string) ([]txtyp.TransactionJsonResult, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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