OSDN Git Service

delete the key index (#335)
[bytom/vapor.git] / protocol / txpool.go
index 957ab6a..bbcee18 100644 (file)
@@ -26,11 +26,11 @@ const (
 var (
        maxCachedErrTxs = 1000
        maxMsgChSize    = 1000
-       maxNewTxNum     = 10000
-       maxOrphanNum    = 2000
+       maxNewTxNum     = 65536
+       maxOrphanNum    = 32768
 
-       orphanTTL                = 10 * time.Minute
-       orphanExpireScanInterval = 3 * time.Minute
+       orphanTTL                = 60 * time.Second
+       orphanExpireScanInterval = 30 * time.Second
 
        // ErrTransactionNotExist is the pre-defined error message
        ErrTransactionNotExist = errors.New("transaction are not existed in the mempool")
@@ -192,19 +192,9 @@ func (tp *TxPool) HaveTransaction(txHash *bc.Hash) bool {
        return tp.IsTransactionInPool(txHash) || tp.IsTransactionInErrCache(txHash)
 }
 
-func isTransactionNoBtmInput(tx *types.Tx) bool {
-       for _, input := range tx.TxData.Inputs {
-               if input.AssetID() == *consensus.BTMAssetID {
-                       return false
-               }
-       }
-       return true
-}
-
 func isTransactionZeroOutput(tx *types.Tx) bool {
        for _, output := range tx.TxData.Outputs {
-               value := output.AssetAmount()
-               if value.Amount == uint64(0) {
+               if value := output.AssetAmount(); value.Amount == uint64(0) {
                        return true
                }
        }
@@ -212,7 +202,7 @@ func isTransactionZeroOutput(tx *types.Tx) bool {
 }
 
 func (tp *TxPool) IsDust(tx *types.Tx) bool {
-       return isTransactionNoBtmInput(tx) || isTransactionZeroOutput(tx)
+       return isTransactionZeroOutput(tx)
 }
 
 func (tp *TxPool) processTransaction(tx *types.Tx, statusFail bool, height, fee uint64) (bool, error) {
@@ -277,11 +267,12 @@ func (tp *TxPool) addTransaction(txD *TxDesc) error {
        txD.Added = time.Now()
        tp.pool[tx.ID] = txD
        for _, id := range tx.ResultIds {
-               var assetID bc.AssetID
                outputEntry, err := tx.Entry(*id)
                if err != nil {
                        return err
                }
+
+               var assetID bc.AssetID
                switch output := outputEntry.(type) {
                case *bc.IntraChainOutput:
                        assetID = *output.Source.Value.AssetId