OSDN Git Service

filter out known txs (#280)
[bytom/vapor.git] / protocol / tx.go
index 6eadc3a..966b292 100644 (file)
@@ -27,6 +27,17 @@ func (c *Chain) GetTransactionsUtxo(view *state.UtxoViewpoint, txs []*bc.Tx) err
 // per-transaction validation results and is consulted before
 // performing full validation.
 func (c *Chain) ValidateTx(tx *types.Tx) (bool, error) {
+       if c.hasSeenTx(tx) {
+               return false, nil
+       }
+
+       c.markTransactions(tx)
+
+       return c.validateTx(tx)
+}
+
+// validateTx validates the given transaction without checking duplication.
+func (c *Chain) validateTx(tx *types.Tx) (bool, error) {
        if ok := c.txPool.HaveTransaction(&tx.ID); ok {
                return false, c.txPool.GetErrCache(&tx.ID)
        }