¿Cómo puedo mostrar en web3j una lista de todos los instructores agregados en mi cadena de bloques?

Necesito mostrar en un html una lista de todos los instructores que están configurados en la lista

pragma solidity ^0.4.18;

contract Owned {
address owner;

function Owned() public {
    owner = msg.sender;
}
modifier onlyOwner {
   require(msg.sender == owner);
   _;
 }
}

contract Courses is Owned {

struct Instructor {
    uint age;
    bytes16 fName;
    bytes16 lName;
}

mapping (address => Instructor) instructors;
address[] public instructorAccts;

event instructorInfo(
   bytes16 fName,
   bytes16 lName,
   uint age
);

function setInstructor(address _address, uint _age, bytes16 _fName, bytes16 _lName) onlyOwner public {
    var instructor = instructors[_address];

    instructor.age = _age;
    instructor.fName = _fName;
    instructor.lName = _lName;

    instructorAccts.push(_address)-1;
    instructorInfo(_fName, _lName, _age);
}

function getInstructors() view public returns(address[]) {
    return instructorAccts;
}

function getInstructor(address _address) view public returns (uint, bytes16, bytes16) {
    return (instructors[_address].age, instructors[_address].fName, instructors[_address].lName);
}

function countInstructors() view public returns (uint) {
    return instructorAccts.length;
}

}

ACTUALIZACIÓN: mi código web3js

  <script>
       if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

web3.eth.defaultAccount = web3.eth.accounts[1];

var CoursetroContract = web3.eth.contract([
{
    "constant": true,
    "inputs": [
        {
            "name": "_address",
            "type": "address"
        }
    ],
    "name": "getInstructor",
    "outputs": [
        {
            "name": "",
            "type": "uint256"
        },
        {
            "name": "",
            "type": "bytes16"
        },
        {
            "name": "",
            "type": "bytes16"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
},
{
    "constant": true,
    "inputs": [],
    "name": "getInstructors",
    "outputs": [
        {
            "name": "",
            "type": "address[]"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
},
{
    "constant": true,
    "inputs": [
        {
            "name": "_index",
            "type": "uint256"
        }
    ],
    "name": "getInstructorAtIndex",
    "outputs": [
        {
            "name": "",
            "type": "uint256"
        },
        {
            "name": "",
            "type": "bytes16"
        },
        {
            "name": "",
            "type": "bytes16"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
},
{
    "constant": true,
    "inputs": [
        {
            "name": "",
            "type": "uint256"
        }
    ],
    "name": "instructorAccts",
    "outputs": [
        {
            "name": "",
            "type": "address"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
},
{
    "constant": true,
    "inputs": [],
    "name": "countInstructors",
    "outputs": [
        {
            "name": "",
            "type": "uint256"
        }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
},
{
    "constant": false,
    "inputs": [
        {
            "name": "_address",
            "type": "address"
        },
        {
            "name": "_age",
            "type": "uint256"
        },
        {
            "name": "_fName",
            "type": "bytes16"
        },
        {
            "name": "_lName",
            "type": "bytes16"
        }
    ],
    "name": "setInstructor",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
       "type": "function"
},
{
    "anonymous": false,
    "inputs": [
        {
            "indexed": false,
            "name": "fName",
            "type": "bytes16"
        },
        {
            "indexed": false,
            "name": "lName",
            "type": "bytes16"
        },
        {
            "indexed": false,
            "name": "age",
            "type": "uint256"
        }
    ],
    "name": "instructorInfo",
    "type": "event"
        }
     ]);

  var Coursetro = 
  CoursetroContract.at('0x13fd9e45bbd7ee860cdfc825839c9dfbd91a36cd');
  var instructorEvent = Coursetro.instructorInfo({}, 'EARLIEST');

instructorEvent.watch(function(error, result) {
    if (result) {
        if (result.blockHash != $("#insTrans").html())
             $("#loader").hide();
         $("#insTrans").html('Block hash: ' + result.blockHash);
        $("#instructor").html(web3.toAscii(result.args.fName) + ' ' + web3.toAscii(result.args.lName) + ' (' + result.args.age + ' Kb)');
    } else {
         $("#loader").hide();
    }
});

Coursetro.countInstructors((err, res) => {
    if (res)
     $("#countIns").html(res.c + ' number of files');
})

$("#button").click(function() {
     //$("#loader").show();
    Coursetro.setInstructor(web3.eth.defaultAccount, $("#age").val(), $("#fName").val(), $("#lName").val(), (err, res) => {
        if (err) {
            $("#loader").hide();
        }
    });
});

Respuestas (1)

Para mostrar una lista de sus instructores, deberá agregar otra función a su contrato inteligente:

function getInstructorAtIndex(uint _index) view public returns (uint, bytes16, bytes16) {
    Instructor storage i = instructors[instructorAccts[index]];
    return (i.age, i.fName, i.lName);
}

Luego, deberá implementar su contrato inteligente en una cadena de bloques de ethereum. Primero pruébalo en una red de prueba como Ropsten. Puede administrar con el marco Remix y la billetera Metamask. ( https://remix.ethereum.org/ ) ( https://metamask.io/ )

Finalmente tendrás que construir una aplicación. Web3j es el conector principal y tiene tres implementaciones: javascript, java y scala. La mayoría de la gente usa Web3js ( https://github.com/ethereum/web3.js/ ) para construir Dapps. De esta manera, también puede usar Truffle framework ( http://truffleframework.com ). Truffle tiene algunos modelos para desarrollar un proyecto de muestra rápidamente.

Espero ayudarte. :-)

PD: Puede configurar su mapeo y matriz como privados en su contrato inteligente. Como lo tiene, el EVM creará automáticamente captadores para ellos.

PSS: puede configurar el modificador "constante" o "puro" para sus funciones de obtención.

Genial, gracias, pero ¿cómo lo uso con web3js? Estoy usando el nodo también.
Actualizo el post con el código web3js
@VictorJoelCuadrosChoez lo siento, pero no estoy tan familiarizado con la programación de jquery y javascript. Y si no nos das todo el contexto es muy difícil ayudarte. Simplemente busque información sobre web3js y sobre la creación de bucles y divs con jquery y js. En Internet puedes encontrar ejemplos útiles de ambos. Buena suerte :)