From: HAOYUatHZ Date: Sun, 9 Jun 2019 00:12:11 +0000 (+0800) Subject: add X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=f66d8607ac2002825476050d571ba4dccedb0724 add --- diff --git a/federation/synchron/block_processor.go b/federation/synchron/block_processor.go index 1d868390..7d0dcf60 100644 --- a/federation/synchron/block_processor.go +++ b/federation/synchron/block_processor.go @@ -99,8 +99,14 @@ func updateBlock(db *gorm.DB, bp blockProcessor) error { default: block := bp.getBlock().(*vaporTypes.Block) - filterDepositToSidechain(block) - filterWithdrawalFromSidechain(block) + for i, tx := range block.Transactions { + if isDepositToSidechain(tx) { + // bp.processDepositToSidechain(uint64(i), tx) + } + if isWithdrawalFromSidechain(tx) { + // bp.processWithdrawalFromSidechain(uint64(i), tx) + } + } } return bp.processChainInfo() @@ -126,28 +132,22 @@ func isWithdrawalToMainchain(tx *btmTypes.Tx) bool { return false } -func filterDepositToSidechain(block *vaporTypes.Block) []*vaporTypes.Tx { - depositTxs := []*vaporTypes.Tx{} - for _, tx := range block.Transactions { - for _, input := range tx.Inputs { - if input.InputType() == vaporTypes.CrossChainInputType { - break - } +func isDepositToSidechain(tx *vaporTypes.Tx) bool { + for _, input := range tx.Inputs { + if input.InputType() == vaporTypes.CrossChainInputType { + return true } } - return depositTxs + return false } -func filterWithdrawalFromSidechain(block *vaporTypes.Block) []*vaporTypes.Tx { - withdrawalTxs := []*vaporTypes.Tx{} - for _, tx := range block.Transactions { - for _, output := range tx.Outputs { - if output.OutputType() == vaporTypes.CrossChainOutputType { - break - } +func isWithdrawalFromSidechain(tx *vaporTypes.Tx) bool { + for _, output := range tx.Outputs { + if output.OutputType() == vaporTypes.CrossChainOutputType { + return true } } - return withdrawalTxs + return false } func getCrossChainInputs(ormTxID uint64, tx *btmTypes.Tx) []*orm.CrossTransactionInput {