Commit e80678c4 authored by hezhengjun's avatar hezhengjun

add status descption

parent 30c2103a
...@@ -476,18 +476,17 @@ func (ethRelayer *Relayer4Ethereum) proc() { ...@@ -476,18 +476,17 @@ func (ethRelayer *Relayer4Ethereum) proc() {
ethRelayer.rwLock.RUnlock() ethRelayer.rwLock.RUnlock()
if nil != privateKey4Ethereum && nilAddr != ethRelayer.bridgeRegistryAddr { if nil != privateKey4Ethereum && nilAddr != ethRelayer.bridgeRegistryAddr {
relayerLog.Info("Ethereum relayer starts to run...") relayerLog.Info("Ethereum relayer starts to run...")
timer = time.NewTicker(time.Duration(ethRelayer.fetchHeightPeriodMs) * time.Millisecond)
ethRelayer.prePareSubscribeEvent() ethRelayer.prePareSubscribeEvent()
//向bridgeBank订阅事件 //向bridgeBank订阅事件
ethRelayer.subscribeEvent() ethRelayer.subscribeEvent()
ethRelayer.filterLogEvents() ethRelayer.filterLogEvents()
relayerLog.Info("Ethereum relayer starts to process online log event...") relayerLog.Info("Ethereum relayer starts to process online log event...")
goto burnLockWithProc timer = time.NewTicker(time.Duration(ethRelayer.fetchHeightPeriodMs) * time.Millisecond)
goto burnLockWithdrawProc
} }
} }
burnLockWithProc: burnLockWithdrawProc:
for { for {
select { select {
case <-timer.C: case <-timer.C:
...@@ -562,13 +561,15 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33 ...@@ -562,13 +561,15 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
Month: int32(month), Month: int32(month),
Day: int32(day), Day: int32(day),
} }
//非代理提币人模式,则不处理代理提币
if !ethRelayer.processWithDraw { if !ethRelayer.processWithDraw {
relayerLog.Info("handleLogWithdraw", "Needn't process withdraw for this relay validator", ethRelayer.ethSender) relayerLog.Info("handleLogWithdraw", "Needn't process withdraw for this relay validator", ethRelayer.ethSender)
return return
} }
defer func() { defer func() {
if err != nil { if err != nil {
withdrawTx.Status = int32(ethtxs.WDError)
withdrawTx.StatusDescription = ethtxs.WDError.String()
withdrawTx.ErrorDescription = err.Error() withdrawTx.ErrorDescription = err.Error()
relayerLog.Error("handleLogWithdraw", "Failed to withdraw due to:", err.Error()) relayerLog.Error("handleLogWithdraw", "Failed to withdraw due to:", err.Error())
} }
...@@ -687,7 +688,8 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33 ...@@ -687,7 +688,8 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
} }
relayerLog.Info("handleLogWithdraw", "SendTransaction Hash", signedTx.Hash()) relayerLog.Info("handleLogWithdraw", "SendTransaction Hash", signedTx.Hash())
withdrawTx.StatusDescription = "Withdraw Tx has been sent to Ethereum" withdrawTx.Status = int32(ethtxs.WDPending)
withdrawTx.StatusDescription = ethtxs.WDPending.String()
withdrawTx.TxHashOnEthereum = signedTx.Hash().String() withdrawTx.TxHashOnEthereum = signedTx.Hash().String()
return return
} }
......
...@@ -9,9 +9,9 @@ import ( ...@@ -9,9 +9,9 @@ import (
//const ... //const ...
const ( const (
X2Eth = "x2ethereum" X2Eth = "x2ethereum"
BurnAction = "Chain33ToEthBurn" BurnAction = "Chain33ToEthBurn"
LockAction = "Chain33ToEthLock" LockAction = "Chain33ToEthLock"
EthNullAddr = "0x0000000000000000000000000000000000000000" EthNullAddr = "0x0000000000000000000000000000000000000000"
) )
...@@ -32,3 +32,17 @@ type ProphecyClaim struct { ...@@ -32,3 +32,17 @@ type ProphecyClaim struct {
Amount *big.Int Amount *big.Int
chain33TxHash []byte chain33TxHash []byte
} }
type WithdrawStatus int32
const (
WDError = WithdrawStatus(1)
WDPending = WithdrawStatus(2)
WDFailed = WithdrawStatus(3)
WDSuccess = WithdrawStatus(4)
)
// 此处的名字命令不能随意改动,需要与合约event中的命名完全一致
func (d WithdrawStatus) String() string {
return [...]string{"undefined", "Error,not submitted to ethereum", "Pending", "Submitted to ethereum, but Failed", "Success"}[d]
}
...@@ -449,7 +449,15 @@ func (ethRelayer *Relayer4Ethereum) setWithdraw(withdrawTx *ebTypes.WithdrawTx) ...@@ -449,7 +449,15 @@ func (ethRelayer *Relayer4Ethereum) setWithdraw(withdrawTx *ebTypes.WithdrawTx)
key := calcWithdrawKey(chain33Sender, symbol, int(year), int(month), int(day), withdrawTx.Nonce) key := calcWithdrawKey(chain33Sender, symbol, int(year), int(month), int(day), withdrawTx.Nonce)
bytes := chain33Types.Encode(withdrawTx) bytes := chain33Types.Encode(withdrawTx)
return ethRelayer.db.Set(key, bytes) if err := ethRelayer.db.Set(key, bytes); nil != err {
return err
}
//保存按照次序提币的交易,方便查询
listKey := calcWithdrawListKey(withdrawTx.Nonce)
listData := key
return ethRelayer.db.Set(listKey, listData)
} }
func (ethRelayer *Relayer4Ethereum) getWithdrawsWithinSameDay(withdrawTx *ebTypes.WithdrawTx) (*big.Int, error) { func (ethRelayer *Relayer4Ethereum) getWithdrawsWithinSameDay(withdrawTx *ebTypes.WithdrawTx) (*big.Int, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment