@@ -45,55 +45,46 @@ data ValidatedInductive h a = ValidatedInductive {
45
45
46
46
data InductiveValidationError h a =
47
47
-- | Bootstrap transaction is invalid
48
- InductiveInvalidBoot {
49
- -- | The bootstrap transaction
50
- inductiveInvalidBoot :: Transaction h a
51
-
52
- -- | The error message
53
- , inductiveInvalidError :: Text
54
- }
48
+ -- InductiveInvalidBoot
49
+ -- inductiveInvalidBoot = The bootstrap transaction
50
+ -- inductiveInvalidError = The error message
51
+ InductiveInvalidBoot ! (Transaction h a ) ! Text
55
52
56
53
-- | Invalid transaction in the given block
57
- | InductiveInvalidApplyBlock {
58
- -- | The events leading up to the error
59
- inductiveInvalidEvents :: OldestFirst [] (WalletEvent h a )
60
-
61
- -- | The transactions in the block we successfully validated
62
- , inductiveInvalidBlockPrefix :: OldestFirst [] (Transaction h a )
63
-
64
- -- | The transaction that was invalid
65
- , inductiveInvalidTransaction :: Transaction h a
66
-
67
- -- | The error message
68
- , inductiveInvalidError :: Text
69
- }
54
+ -- InductiveInvalidApplyBlock
55
+ -- inductiveInvalidEvents = The events leading up to the error
56
+ -- inductiveInvalidBlockPrefix = The transactions in the block we
57
+ -- successfully validated
58
+ -- inductiveInvalidTransaction = The transaction that was invalid
59
+ -- inductiveInvalidError = The error message
60
+ | InductiveInvalidApplyBlock
61
+ ! (OldestFirst [] (WalletEvent h a ))
62
+ ! (OldestFirst [] (Transaction h a ))
63
+ ! (Transaction h a )
64
+ ! Text
70
65
71
66
-- | A 'NewPending' call was invalid because the input was already spent
72
- | InductiveInvalidNewPendingAlreadySpent {
73
- -- | The events leading up to the error
74
- inductiveInvalidEvents :: OldestFirst [] (WalletEvent h a )
75
-
76
- -- | The transaction that was invalid
77
- , inductiveInvalidTransaction :: Transaction h a
78
-
79
- -- | The specific input that was not valid
80
- , inductiveInvalidInput :: Input h a
81
- }
67
+ -- InductiveInvalidNewPendingAlreadySpent
68
+ -- inductiveInvalidEvents = The events leading up to the error
69
+ -- inductiveInvalidTransaction = The transaction that was invalid
70
+ -- inductiveInvalidInput = The specific input that was not valid
71
+ | InductiveInvalidNewPendingAlreadySpent
72
+ ! (OldestFirst [] (WalletEvent h a ))
73
+ ! (Transaction h a )
74
+ ! (Input h a )
82
75
83
76
-- | A 'NewPending' call was invalid because the input was not @ours@
84
- | InductiveInvalidNewPendingNotOurs {
85
- -- | The events leading up to the error
86
- inductiveInvalidEvents :: OldestFirst [] (WalletEvent h a )
87
-
88
- -- | The transaction that was invalid
89
- , inductiveInvalidTransaction :: Transaction h a
77
+ -- InductiveInvalidNewPendingNotOurs
78
+ -- inductiveInvalidEvents = The events leading up to the error
79
+ -- inductiveInvalidTransaction = The transaction that was invalid
80
+ -- inductiveInvalidInput = The specific input that was not valid
81
+ -- inductiveInvalidAddress = The address this input belonged to
82
+ | InductiveInvalidNewPendingNotOurs
83
+ ! (OldestFirst [] (WalletEvent h a ))
84
+ ! (Transaction h a )
85
+ ! (Input h a )
86
+ ! a
90
87
91
- -- | The specific input that was not valid
92
- , inductiveInvalidInput :: Input h a
93
-
94
- -- | The address this input belonged to
95
- , inductiveInvalidAddress :: a
96
- }
97
88
98
89
{- ------------------------------------------------------------------------------
99
90
Validation proper
@@ -150,19 +141,20 @@ inductiveIsValid Inductive{..} = do
150
141
forM_ (zip inputs resolved) $ \ (input, mAddr) ->
151
142
case mAddr of
152
143
Nothing ->
153
- throwError InductiveInvalidNewPendingAlreadySpent {
154
- inductiveInvalidEvents = toOldestFirst viEvents
155
- , inductiveInvalidTransaction = t
156
- , inductiveInvalidInput = input
157
- }
144
+ throwError
145
+ $ InductiveInvalidNewPendingAlreadySpent
146
+ (toOldestFirst viEvents)
147
+ t
148
+ input
158
149
Just addr ->
159
150
unless (addr `Set.member` inductiveOurs) $
160
- throwError InductiveInvalidNewPendingNotOurs {
161
- inductiveInvalidEvents = toOldestFirst viEvents
162
- , inductiveInvalidTransaction = t
163
- , inductiveInvalidInput = input
164
- , inductiveInvalidAddress = addr
165
- }
151
+ throwError
152
+ $ InductiveInvalidNewPendingNotOurs
153
+ (toOldestFirst viEvents)
154
+ t
155
+ input
156
+ addr
157
+
166
158
goEvents es vi
167
159
168
160
goBlock :: OldestFirst [] (WalletEvent h a ) -- Events leading to this point (for err msgs)
@@ -201,15 +193,21 @@ inductiveIsValid Inductive{..} = do
201
193
-------------------------------------------------------------------------------}
202
194
203
195
instance (Hash h a , Buildable a ) => Buildable (InductiveValidationError h a ) where
204
- build InductiveInvalidBoot {.. } = bprint
196
+ build (InductiveInvalidBoot
197
+ inductiveInvalidBoot
198
+ inductiveInvalidError) = bprint
205
199
( " InductiveInvalidBoot"
206
200
% " { boot: " % build
207
201
% " , error: " % build
208
202
% " }"
209
203
)
210
204
inductiveInvalidBoot
211
205
inductiveInvalidError
212
- build InductiveInvalidApplyBlock {.. } = bprint
206
+ build (InductiveInvalidApplyBlock
207
+ inductiveInvalidEvents
208
+ inductiveInvalidBlockPrefix
209
+ inductiveInvalidTransaction
210
+ inductiveInvalidError) = bprint
213
211
( " InductiveInvalidApplyBlock"
214
212
% " { events: " % build
215
213
% " , blockPrefix: " % build
@@ -220,7 +218,10 @@ instance (Hash h a, Buildable a) => Buildable (InductiveValidationError h a) whe
220
218
inductiveInvalidBlockPrefix
221
219
inductiveInvalidTransaction
222
220
inductiveInvalidError
223
- build InductiveInvalidNewPendingAlreadySpent {.. } = bprint
221
+ build (InductiveInvalidNewPendingAlreadySpent
222
+ inductiveInvalidEvents
223
+ inductiveInvalidTransaction
224
+ inductiveInvalidInput) = bprint
224
225
( " InductiveInvalidNewPendingAlreadySpent"
225
226
% " { events: " % build
226
227
% " , transaction: " % build
@@ -230,7 +231,11 @@ instance (Hash h a, Buildable a) => Buildable (InductiveValidationError h a) whe
230
231
inductiveInvalidEvents
231
232
inductiveInvalidTransaction
232
233
inductiveInvalidInput
233
- build InductiveInvalidNewPendingNotOurs {.. } = bprint
234
+ build (InductiveInvalidNewPendingNotOurs
235
+ inductiveInvalidEvents
236
+ inductiveInvalidTransaction
237
+ inductiveInvalidInput
238
+ inductiveInvalidAddress) = bprint
234
239
( " InductiveInvalidNewPendingNotOurs"
235
240
% " { events: " % build
236
241
% " , transaction: " % build
0 commit comments