@@ -229,23 +229,35 @@ export default class RequestLogic implements Types.IRequestLogic {
229229 public async getRequestFromId ( requestId : string ) : Promise < Types . IReturnGetRequestFromId > {
230230 const resultGetTx = await this . transactionManager . getTransactionsByChannelId ( requestId ) ;
231231 const actions = resultGetTx . result . transactions ;
232+ let ignoredTransactions : any [ ] = [ ] ;
232233
233234 // array of transaction without duplicates to avoid replay attack
234235 const actionsConfirmedWithoutDuplicates = Utils . uniqueByProperty (
235236 actions
236237 . map ( ( t : any ) => {
237- // We ignore the transaction.data that cannot be parsed
238238 try {
239239 return { action : JSON . parse ( t . transaction . data ) , timestamp : t . timestamp } ;
240240 } catch ( e ) {
241+ // We ignore the transaction.data that cannot be parsed
242+ ignoredTransactions . push ( {
243+ reason : 'JSON parsing error' ,
244+ transaction : t ,
245+ } ) ;
241246 return ;
242247 }
243248 } )
244249 . filter ( ( elem : any ) => elem !== undefined ) ,
245250 'action' ,
246251 ) ;
247252 // Keeps the transaction ignored
248- const ignoredTransactions = actionsConfirmedWithoutDuplicates . duplicates ;
253+ ignoredTransactions = ignoredTransactions . concat (
254+ actionsConfirmedWithoutDuplicates . duplicates . map ( tx => {
255+ return {
256+ reason : 'Duplicated transaction' ,
257+ transaction : tx ,
258+ } ;
259+ } ) ,
260+ ) ;
249261
250262 // second parameter is null, because the first action must be a creation (no state expected)
251263 const request = actionsConfirmedWithoutDuplicates . uniqueItems . reduce (
@@ -259,7 +271,7 @@ export default class RequestLogic implements Types.IRequestLogic {
259271 ) ;
260272 } catch ( e ) {
261273 // if an error occurs during the apply we ignore the action
262- ignoredTransactions . push ( actionConfirmed . action ) ;
274+ ignoredTransactions . push ( { reason : e . message , transaction : actionConfirmed } ) ;
263275 return requestState ;
264276 }
265277 } ,
@@ -296,21 +308,33 @@ export default class RequestLogic implements Types.IRequestLogic {
296308 const allRequestAndMeta = Object . keys ( getChannelsResult . result . transactions ) . map ( channelId => {
297309 // Parses and removes corrupted or duplicated transactions
298310
311+ let ignoredTransactions : any [ ] = [ ] ;
312+
299313 const actionsConfirmedWithoutDuplicates = Utils . uniqueByProperty (
300314 transactionsByChannel [ channelId ]
301315 . map ( ( t : any ) => {
302- // We ignore the transaction.data that cannot be parsed
303316 try {
304317 return { action : JSON . parse ( t . transaction . data ) , timestamp : t . timestamp } ;
305318 } catch ( e ) {
319+ // We ignore the transaction.data that cannot be parsed
320+ ignoredTransactions . push ( {
321+ reason : 'JSON parsing error' ,
322+ transaction : t ,
323+ } ) ;
306324 return ;
307325 }
308326 } )
309327 . filter ( ( elem : any ) => elem !== undefined ) ,
310328 'action' ,
311329 ) ;
330+
312331 // Keeps the transaction ignored
313- const ignoredTransactions = actionsConfirmedWithoutDuplicates . duplicates ;
332+ ignoredTransactions = ignoredTransactions . concat (
333+ actionsConfirmedWithoutDuplicates . duplicates . map ( tx => ( {
334+ reason : 'Duplicated transaction' ,
335+ transaction : tx ,
336+ } ) ) ,
337+ ) ;
314338
315339 // second parameter is null, because the first action must be a creation (no state expected)
316340 const request = actionsConfirmedWithoutDuplicates . uniqueItems . reduce (
@@ -324,7 +348,7 @@ export default class RequestLogic implements Types.IRequestLogic {
324348 ) ;
325349 } catch ( e ) {
326350 // if an error occurs during the apply we ignore the action
327- ignoredTransactions . push ( actionConfirmed ) ;
351+ ignoredTransactions . push ( { reason : e . message , transaction : actionConfirmed } ) ;
328352 return requestState ;
329353 }
330354 } ,
0 commit comments