ValidateTx validates the given transaction. A cache holds per-transaction validation results and is consulted before performing full validation.
(tx *bc.Tx)
| 17 | // per-transaction validation results and is consulted before |
| 18 | // performing full validation. |
| 19 | func (c *Chain) ValidateTx(tx *bc.Tx) error { |
| 20 | err := c.checkIssuanceWindow(tx) |
| 21 | if err != nil { |
| 22 | return err |
| 23 | } |
| 24 | var ok bool |
| 25 | err, ok = c.prevalidated.lookup(tx.ID) |
| 26 | if !ok { |
| 27 | err = validation.ValidateTx(tx, c.InitialBlockHash) |
| 28 | c.prevalidated.cache(tx.ID, err) |
| 29 | } |
| 30 | return errors.Sub(ErrBadTx, err) |
| 31 | } |
| 32 | |
| 33 | type prevalidatedTxsCache struct { |
| 34 | mu sync.Mutex |
no test coverage detected