checkTransactionTime ensures that a transaction is fit to be included in a block generated at blockTimeMS.
(tx *bc.Tx, blockTimeMS uint64)
| 154 | // checkTransactionTime ensures that a transaction is fit |
| 155 | // to be included in a block generated at blockTimeMS. |
| 156 | func (bb *BlockBuilder) checkTransactionTime(tx *bc.Tx, blockTimeMS uint64) error { |
| 157 | for _, tr := range tx.Timeranges { |
| 158 | if tr.MaxMS > 0 && blockTimeMS > uint64(tr.MaxMS) { |
| 159 | return ErrTxTooOld |
| 160 | } |
| 161 | if tr.MinMS > 0 && blockTimeMS > 0 && blockTimeMS < uint64(tr.MinMS) { |
| 162 | return ErrTxTooNew |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if bb.MaxNonceWindow > 0 { |
| 167 | for _, nonce := range tx.Nonces { |
| 168 | if nonce.ExpMS > bc.DurationMillis(bb.MaxNonceWindow)+blockTimeMS { |
| 169 | return ErrTxLongNonce |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | return nil |
| 174 | } |