From eed2925cbcd0f608142744e2248606471e35bb44 Mon Sep 17 00:00:00 2001 From: KamiD <44460798+KamiD@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:26:18 +0800 Subject: [PATCH] Merge PR: Add two hours buffer-time before VenusHeight upgrade to close txPool (#1415) * add 2 hours buffer of VenusHeight upgrade to close txPool * optimize code --- app/rpc/namespaces/eth/api.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/rpc/namespaces/eth/api.go b/app/rpc/namespaces/eth/api.go index d6ff502636..3625b01a76 100644 --- a/app/rpc/namespaces/eth/api.go +++ b/app/rpc/namespaces/eth/api.go @@ -717,8 +717,13 @@ func (api *PublicEthereumAPI) SendTransaction(args rpctypes.SendTxArgs) (common. return common.Hash{}, err } + //todo: after upgrade of VenusHeight, this code need to be deleted, 1800 means two hours before arriving VenusHeight + VenusTxPoolHeight := int64(0) + if tmtypes.GetVenusHeight() > 1800 { + VenusTxPoolHeight = tmtypes.GetVenusHeight() - 1800 + } // send chanData to txPool - if tmtypes.HigherThanVenus(int64(height)) && api.txPool != nil { + if (int64(height) < VenusTxPoolHeight || tmtypes.HigherThanVenus(int64(height))) && api.txPool != nil { return broadcastTxByTxPool(api, tx, txBytes) } @@ -761,8 +766,13 @@ func (api *PublicEthereumAPI) SendRawTransaction(data hexutil.Bytes) (common.Has } } + //todo: after upgrade of VenusHeight, this code need to be deleted, 1800 means two hours before arriving VenusHeight + VenusTxPoolHeight := int64(0) + if tmtypes.GetVenusHeight() > 1800 { + VenusTxPoolHeight = tmtypes.GetVenusHeight() - 1800 + } // send chanData to txPool - if tmtypes.HigherThanVenus(int64(height)) && api.txPool != nil { + if (int64(height) < VenusTxPoolHeight || tmtypes.HigherThanVenus(int64(height))) && api.txPool != nil { return broadcastTxByTxPool(api, tx, txBytes) }