Проблема с производительностью при получении сведений о транзакции из цепочки блоков кворума - PullRequest
1 голос
/ 24 апреля 2019

У меня возникла проблема с производительностью при получении сведений о транзакции, таких как инициатор транзакции и получатель транзакции, из цепочки блоков Кворума.

Цикл Javascript For и Web3.eth.contract (abi) .at (address2) .totalTransactions используются для получения сведений о транзакции и последующего добавления в таблицу HTML.

Моя проблема с производительностью заключается в том, чтоизвлечение нескольких строк данных транзакции из блокчейна Quorum занимает около 30 секунд.

Более того, я использую web3-quorum@0.1.1 и quorum-js@0.3.0.

Пожалуйстаконсультировать.Благодарю.

С уважением, Уилсон

   $('#get-tran').click(() => {
  // Get Tran History
  var tranId = 0;
  let w2Contract=web3w2.eth.contract(abi).at(address2);
  let tottr = w2Contract.totalTransactions();
  //Clear the old table content first
   $("#t02 tr").remove();

  var i=0;
  for (i = 0; i <= w2Contract.totalTransactions()-1; i++) {
    tranId = i;
    let tranHash = w2Contract.transactionIDs(i);
  let trDetails1 = w2Contract.transactions(tranHash);
  console.log(`Tran details ${trDetails1}`);
  console.log(`Tran Detail 1: ${trDetails1[1]}`);
  console.log(`Tran Detail 2: ${trDetails1[2]}`);
  console.log(`Tran Detail 0: ${trDetails1[0]}`);
  var tableRef =   document.getElementById('t02').getElementsByTagName('tbody')[0];
  // Insert a row at the end of the table
  let newRow = tableRef.insertRow(-1);

  // Insert a cell in the row at index 0
  let newCell = newRow.insertCell(0);
  // Append a text node to the cell
  let newText = document.createTextNode(`${tranId}`);
  newCell.appendChild(newText);

    // Insert a cell in the row at index 1
    let newCell1 = newRow.insertCell(1);
    // Append a text node to the cell
    let newText1 = document.createTextNode(`${trDetails1[1]}`);
    console.log(`newText1 at index 1 ${newText1}`);
        // w2 > w1
        if ((trDetails1[1] == '0xf9a2cb34b6b5fd7a2ac0c2e9b2b9406d6daffbd4') && 
        (trDetails1[2] == '0x180893a0ec847fa8c92786791348d7d65916acbb')) {
          newText1.textContent = 'Stock In'
        } else if  
          (trDetails1[1] == '0x180893a0ec847fa8c92786791348d7d65916acbb') {
          newText1.textContent = 'Pier Company'
        } else if (trDetails1[1] == '0xf9a2cb34b6b5fd7a2ac0c2e9b2b9406d6daffbd4') {
          newText1.textContent = 'Warehouse Company'
        }  
        newCell1.appendChild(newText1);

        // Insert a cell in the row at index 2
        let newCell2 = newRow.insertCell(2);
        // Append a text node to the cell
        let newText2 = document.createTextNode(`${trDetails1[2]}`);
        console.log(`newText1 at index 2 ${newText1}`);

        if (trDetails1[2] == '0xf9a2cb34b6b5fd7a2ac0c2e9b2b9406d6daffbd4') {
          newText2.textContent = 'Warehouse Company'
        }  
        if (trDetails1[2] == '0x180893a0ec847fa8c92786791348d7d65916acbb') {
          newText2.textContent = 'Pier Company'
        }
        if (trDetails1[2] == '0xc8f717ba9593dc9d45c4518cf444d2cbd08af24d') {
          newText2.textContent = 'Removal'
        }
          newCell2.appendChild(newText2);

    // Insert a cell in the row at index 3
    let newCell3 = newRow.insertCell(3);
    // Append a text node to the cell
    let newText3 = document.createTextNode(`${trDetails1[0]}`);
    console.log(`newText3 at index 3 ${newText3}`);
    newCell3.appendChild(newText3);

        // Insert a cell in the row at index 4
        let newCell4 = newRow.insertCell(4);
        // Append a text node to the cell
        let newText4 = document.createTextNode(`${trDetails1[3]}`);
        console.log(`newText1 at index 4 ${newText4}`);
        if (trDetails1[3] ) {
          newText4.textContent = 'Confirmed'
        } else {
          newText4.textContent = 'Pending'
        }  
        newCell4.appendChild(newText4);
     }

});
...