@ -57,9 +57,9 @@ type Transaction struct {
time time . Time // Time first seen locally (spam avoidance)
time time . Time // Time first seen locally (spam avoidance)
// caches
// caches
hash atomic . Value
hash atomic . Pointer [ common . Hash ]
size atomic . Value
size atomic . Uint64
from atomic . Value
from atomic . Pointer [ sigCache ]
}
}
// NewTx creates a new transaction.
// NewTx creates a new transaction.
@ -462,7 +462,7 @@ func (tx *Transaction) Time() time.Time {
// Hash returns the transaction hash.
// Hash returns the transaction hash.
func ( tx * Transaction ) Hash ( ) common . Hash {
func ( tx * Transaction ) Hash ( ) common . Hash {
if hash := tx . hash . Load ( ) ; hash != nil {
if hash := tx . hash . Load ( ) ; hash != nil {
return hash . ( common . Hash )
return * hash
}
}
var h common . Hash
var h common . Hash
@ -471,15 +471,15 @@ func (tx *Transaction) Hash() common.Hash {
} else {
} else {
h = prefixedRlpHash ( tx . Type ( ) , tx . inner )
h = prefixedRlpHash ( tx . Type ( ) , tx . inner )
}
}
tx . hash . Store ( h )
tx . hash . Store ( & h )
return h
return h
}
}
// Size returns the true encoded storage size of the transaction, either by encoding
// Size returns the true encoded storage size of the transaction, either by encoding
// and returning it, or returning a previously cached value.
// and returning it, or returning a previously cached value.
func ( tx * Transaction ) Size ( ) uint64 {
func ( tx * Transaction ) Size ( ) uint64 {
if size := tx . size . Load ( ) ; size != nil {
if size := tx . size . Load ( ) ; size > 0 {
return size . ( uint64 )
return size
}
}
// Cache miss, encode and cache.
// Cache miss, encode and cache.