MCPcopy Create free account
hub / github.com/chain/txvm / checkTransactionTime

Method checkTransactionTime

protocol/builder.go:156–174  ·  view source on GitHub ↗

checkTransactionTime ensures that a transaction is fit to be included in a block generated at blockTimeMS.

(tx *bc.Tx, blockTimeMS uint64)

Source from the content-addressed store, hash-verified

154// checkTransactionTime ensures that a transaction is fit
155// to be included in a block generated at blockTimeMS.
156func (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}

Callers 1

AddTxMethod · 0.95

Calls 1

DurationMillisFunction · 0.92

Tested by

no test coverage detected