File tree 1 file changed +13
-13
lines changed 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -108,27 +108,27 @@ type extraConstructors struct {
108
108
}
109
109
110
110
func (h * Header ) extraPayload () * pseudo.Type {
111
- r := registeredExtras
112
- if ! r .Registered () {
113
- // See params.ChainConfig.extraPayload() for panic rationale.
114
- panic (fmt .Sprintf ("%T.extraPayload() called before RegisterExtras()" , r ))
115
- }
116
- if h .extra == nil {
117
- h .extra = r .Get ().newHeader ()
118
- }
119
- return h .extra
111
+ return extraPayloadOrSetDefault (& h .extra , func (c * extraConstructors ) * pseudo.Type {
112
+ return c .newHeader ()
113
+ })
120
114
}
121
115
122
116
func (b * Body ) extraPayload () * pseudo.Type {
117
+ return extraPayloadOrSetDefault (& b .extra , func (c * extraConstructors ) * pseudo.Type {
118
+ return c .newBody ()
119
+ })
120
+ }
121
+
122
+ func extraPayloadOrSetDefault (field * * pseudo.Type , construct func (* extraConstructors ) * pseudo.Type ) * pseudo.Type {
123
123
r := registeredExtras
124
124
if ! r .Registered () {
125
125
// See params.ChainConfig.extraPayload() for panic rationale.
126
- panic (fmt . Sprintf ( "%T .extraPayload() called before RegisterExtras()", r ) )
126
+ panic ("<T> .extraPayload() called before RegisterExtras()" )
127
127
}
128
- if b . extra == nil {
129
- b . extra = r .Get (). newBody ( )
128
+ if * field == nil {
129
+ * field = construct ( r .Get ())
130
130
}
131
- return b . extra
131
+ return * field
132
132
}
133
133
134
134
// hooks returns the [Header]'s registered [HeaderHooks], if any, otherwise a
You can’t perform that action at this time.
0 commit comments