dominant-strategies / go-quai

Official Go Implementation of the Quai Network
GNU General Public License v3.0
2.36k stars 456 forks source link

Guards on chained methods on types #1901

Open kiltsonfire opened 2 weeks ago

kiltsonfire commented 2 weeks ago

Rationale

Chained methods on our types can cause crashes if a method or a field in a struct is nil

Implementation

Should we put guards on these? Do we know these fields/method returns will always be non-nil?

Example: // Type returns the transaction type. func (tx *Transaction) Type() uint8 { return tx.inner.txType() }

// ChainId returns the chain ID of the transaction. The return value will always be // non-nil. func (tx Transaction) ChainId() big.Int { return tx.inner.chainID() }

jdowning100 commented 2 weeks ago

As far as I know those fields should never be nil in a transaction.