从法定区块链检索交易明细时的性能问题

时间:2019-04-24 08:39:26

标签: blockchain quorum

我在检索交易详细信息(例如交易发起人和交易接收人)时遇到性能问题 来自Quorum区块链。

Java脚本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);
     }

});

0 个答案:

没有答案