MCPcopy Create free account
hub / github.com/chain/Core / ValidateTx

Method ValidateTx

protocol/tx.go:19–31  ·  view source on GitHub ↗

ValidateTx validates the given transaction. A cache holds per-transaction validation results and is consulted before performing full validation.

(tx *bc.Tx)

Source from the content-addressed store, hash-verified

17// per-transaction validation results and is consulted before
18// performing full validation.
19func (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
33type prevalidatedTxsCache struct {
34 mu sync.Mutex

Callers 2

GenerateBlockMethod · 0.95
FinalizeTxFunction · 0.80

Calls 4

checkIssuanceWindowMethod · 0.95
cacheMethod · 0.80
lookupMethod · 0.45
SubMethod · 0.45

Tested by

no test coverage detected