<commit_before>package protocol

import (
	"context"
	"time"

	"chain/errors"
	"chain/protocol/bc"
	"chain/protocol/validation"
)

// AddTx inserts tx into the set of "pending" transactions available
// to be included in the next block produced by GenerateBlock.
//
// It performs context-free validation of the tx, but does not validate
// against the current state tree.
//
// It is okay to add the same transaction more than once; subsequent
// attempts will have no effect and return a nil error.
//
// It is okay to add conflicting transactions to the pool. The conflict
// will be resolved when a block lands.
//
// It is an error to call AddTx before the initial block has landed.
// Use WaitForBlock to guarantee this.
func (c *Chain) AddTx(ctx context.Context, tx *bc.Tx) error {
	// Check if this transaction's max time has already elapsed.
	// We purposely do not check the min time, because we can still
	// add it to the pool if it hasn't been reached yet.
	if tx.MaxTime > 0 && bc.Millis(time.Now()) > tx.MaxTime {
		return errors.WithDetail(validation.ErrBadTx, "transaction max time has passed")
	}

	err := c.validateTxCached(tx)
	if err != nil {
		return errors.Wrap(err, "tx rejected")
	}

	// Update persistent tx pool state.
	err = c.pool.Insert(ctx, tx)
	return errors.Wrap(err, "applying tx to store")
}<commit_msg>protocol: don't check MaxTime on AddTx<commit_after>package protocol

import (
	"context"

	"chain/errors"
	"chain/protocol/bc"
)

// AddTx inserts tx into the set of "pending" transactions available
// to be included in the next block produced by GenerateBlock.
//
// It performs context-free validation of the tx, but does not validate
// against the current state tree.
//
// It is okay to add the same transaction more than once; subsequent
// attempts will have no effect and return a nil error.
//
// It is okay to add conflicting transactions to the pool. The conflict
// will be resolved when a block lands.
//
// It is an error to call AddTx before the initial block has landed.
// Use WaitForBlock to guarantee this.
func (c *Chain) AddTx(ctx context.Context, tx *bc.Tx) error {
	err := c.validateTxCached(tx)
	if err != nil {
		return errors.Wrap(err, "tx rejected")
	}

	// Update persistent tx pool state.
	err = c.pool.Insert(ctx, tx)
	return errors.Wrap(err, "applying tx to store")
}
{'fraction_non_alphanumeric': 0.09841677364142062, 'fraction_numerical': 0.0004278990158322636, 'mean_word_length': 3.4618320610687023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6386385', 'n_tokens_mistral': 695, 'n_tokens_neox': 676, 'n_words': 315}