@@ -333,11 +333,13 @@ function storeTransaction($is_valid_shop, $transaction_ash, $web_hook_status, $a
333
333
$ query = "INSERT INTO testtransactions ( " .join (', ' ,array_keys ($ fields ));
334
334
$ query = $ query .',time) VALUES ( ' .join (', ' ,$ val ).', ' .time ().') ' ;
335
335
336
- $ cluster = Cassandra::cluster ('127.0.0.1 ' ) ->withCredentials ("transactions_rw " , "Private_access_transactions " )->build ();
337
336
$ keyspace = 'comchain ' ;
338
- $ session1 = $ cluster ->connect ($ keyspace );
339
-
340
- $ session1 ->execute (new Cassandra \SimpleStatement ($ query ), array ('arguments ' => $ fields ));
337
+ // for pledge only the other direction is inserted
338
+ if ($ trans_type !='Pledge ' ) {
339
+ $ cluster = Cassandra::cluster ('127.0.0.1 ' ) ->withCredentials ("transactions_rw " , "Private_access_transactions " )->build ();
340
+ $ session1 = $ cluster ->connect ($ keyspace );
341
+ $ session1 ->execute (new Cassandra \SimpleStatement ($ query ), array ('arguments ' => $ fields ));
342
+ }
341
343
342
344
$ cluster2 = Cassandra::cluster ('127.0.0.1 ' ) ->withCredentials ("transactions_rw " , "Private_access_transactions " )->build ();
343
345
$ session2 = $ cluster2 ->connect ($ keyspace );
@@ -378,6 +380,7 @@ function sendRawTransaction($rawtx,$gethRPC){
378
380
// Direct From On Behalf Accept Request
379
381
$ transfert_NA_functions = ['a5f7c148 ' ,'58258353 ' ,'1b6b1ee5 ' ,'132019f4 ' ];
380
382
$ transfert_CM_functions = ['60ca9c4c ' ,'2ef9ade2 ' ,'74c421fe ' ,'1415707c ' ];
383
+ $ pledge_function = '6c343eef ' ;
381
384
$ transfert_functs = array_merge ($ transfert_NA_functions ,$ transfert_CM_functions );
382
385
383
386
$ lock_error = 'Account_Locked_Error ' ;
@@ -421,9 +424,10 @@ function sendRawTransaction($rawtx,$gethRPC){
421
424
// get the amount
422
425
$ amount = hexdec (substr ($ tr_info ,-64 ));
423
426
424
- // get the infos
425
- $ from_status = getAccStatus ($ from_add , $ contract );
426
- $ to_status = getAccStatus ($ to_add , $ contract );
427
+ // get the infos
428
+ $ status = getAccountStatus (array ($ from_add , $ to_add ), $ contract );
429
+ $ from_status = $ status [$ from_add ];
430
+ $ to_status = $ status [$ to_add ];
427
431
428
432
429
433
$ from_Nt_bal = getNTBalance ($ from_add , $ contract );
@@ -481,15 +485,18 @@ function sendRawTransaction($rawtx,$gethRPC){
481
485
$ contract = getContract1 (substr ($ tr_info ,0 ,40 ));
482
486
$ contract2 = '0x ' .substr ($ tr_info ,0 ,40 );
483
487
488
+ // get the dest
489
+ $ dest = '0x ' .substr ($ tr_info ,78 ,40 );
490
+ // get the amount
491
+ $ amount = hexdec (substr ($ tr_info ,-64 ));
484
492
485
493
if (in_my_array ($ funct_address , $ transfert_functs )) {
486
- // get the dest
487
- $ dest = '0x ' .substr ($ tr_info ,78 ,40 );
488
- // get the amount
489
- $ amount = hexdec (substr ($ tr_info ,-64 ));
494
+
495
+
496
+ $ status = getAccountStatus (array ($ sender , $ dest ), $ contract );
497
+ $ from_status = $ status [$ sender ];
498
+ $ to_status = $ status [$ dest ];
490
499
491
- $ from_status = getAccStatus ($ sender , $ contract );
492
- $ to_status = getAccStatus ($ dest , $ contract );
493
500
if ($ from_status ==1 && $ to_status ==1 ) {
494
501
if ($ funct_address ==$ transfert_NA_functions [0 ] ||
495
502
$ funct_address ==$ transfert_CM_functions [0 ] ||
@@ -582,8 +589,18 @@ function sendRawTransaction($rawtx,$gethRPC){
582
589
throw new Exception ($ lock_error );
583
590
}
584
591
585
- }
592
+ } else if ($ pledge_function == $ funct_address ) {
593
+ // We have a pledge:
594
+ $ trans_type = 'Pledge ' ;
595
+ $ from_add = 'Admin ' ;
596
+ $ to_add = $ dest ;
586
597
598
+ $ acctype = getAccType ($ sender , $ contract );
599
+ $ status = getAccountStatus (array ($ sender ), $ contract );
600
+ $ curr_stat = $ status [$ sender ];
601
+
602
+ $ need_pending = $ acctype ==2 && $ curr_stat ==1 ;
603
+ }
587
604
}
588
605
589
606
@@ -607,9 +624,11 @@ function sendRawTransaction($rawtx,$gethRPC){
607
624
$ wh_status = 2 ;
608
625
}
609
626
}
610
- storeAdditionalData (strlen ($ shop_url )>0 , $ data ['data ' ], $ wh_status );
627
+ // Storing the memos, shop and/or delegate
628
+ storeAdditionalData (strlen ($ shop_url )>0 , $ data ['data ' ], $ wh_status );
611
629
612
630
if ($ need_pending ) {
631
+ // adding pending transaction
613
632
storeTransaction (strlen ($ shop_url )>0 , $ data ['data ' ], $ wh_status , $ amount , $ from_add , $ to_add , $ trans_type );
614
633
}
615
634
0 commit comments