adjustemnts

This commit is contained in:
team-devstage 2020-12-07 20:02:18 +01:00 committed by Ulf Gebhardt
parent 2893c51b01
commit 49c41b53eb
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
4 changed files with 18 additions and 5 deletions

View File

@ -63,7 +63,7 @@ class JsonRpcRequestClientComponent extends Component
//$responseType = $response->getType();
return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json'];
}
return $json;
return $json['result'];
//return ['state' => 'success', 'data' => $json];
}

View File

@ -82,10 +82,13 @@ class JsonRequestHandlerController extends AppController {
}
$group_alias = Configure::read('GroupAlias');
$result = (array)$this->JsonRpcRequestClient->request('getTransactions', ['groupAlias' => $group_alias, 'lastKnownSequenceNumber' => $last_transaction_id]);
$result = $this->JsonRpcRequestClient->request('getTransactions', ['groupAlias' => $group_alias, 'lastKnownSequenceNumber' => $last_transaction_id]);
if(isset($result['state']) && $result['state'] == 'error') {
return $this->returnJson(['state' => 'error', 'msg' => 'jsonrpc error', 'details' => $result]);
}
if(!isset($result['transaction_count']) || $result['transaction_count'] == 0) {
return $this->returnJson(['state' => 'success']);
}
/* example
$result = json_decode("[
{
@ -222,7 +225,12 @@ class JsonRequestHandlerController extends AppController {
$part_count = -1;
$temp_record = new Record;
$errors = [];
foreach($result as $_record) {
foreach($result['blocks'] as $_record) {
if(is_string($_record)) {
// if it is a string, it is block validation hash in hex
continue;
}
$parse_result = $temp_record->parseRecord($_record);
if($parse_result == true) {
$sequenceNumber = $temp_record->getSequenceNumber();

View File

@ -332,6 +332,9 @@ class Record
public function parseRecord($json) {
if(!isset($json['record_type'])) {
return false;
}
//var_dump($json);
switch($json['record_type']) {
case 'GRADIDO_TRANSACTION':
@ -378,7 +381,9 @@ class Record
$newTransaction->id = $this->sequenceNumber;
$newTransaction->transaction_type_id = $transactionTypeResults->first()->id;
$newTransaction->memo = $this->memo;
$newTransaction->tx_hash = hex2bin($this->runningHash);
if($this->runningHash != '') {
$newTransaction->tx_hash = hex2bin($this->runningHash);
}
$newTransaction->received = $this->received;
//! TODO change into transaction, if at least one fail, rollback

@ -1 +1 @@
Subproject commit 81a461566e46d71533dc3e284fa075d7d68fd020
Subproject commit 9004e6978ac3dafcc635b2ffcf8bc6a156451cca