I have a function that, according to the Unique ID of the car, gives me all its characteristics:
function getCarArray(uint _carId)
public
view
returns (uint[12] memory)
{
CarData memory car = cars[_carId];
uint[12] memory carInfo;
carInfo[0] = car.statusEnd;
carInfo[1] = car.number;
carInfo[2] = car.load;
carInfo[3] = car.capacity;
carInfo[4] = car.region;
carInfo[5] = car.status;
carInfo[6] = car.abrasion;
carInfo[7] = car.repairs;
carInfo[8] = uint(car.currentOwner);
carInfo[9] = uint(car.movingTo);
carInfo[10] = car.resourceType;
carInfo[11] = car.resourceAmount;
return carInfo;
}
When I call this method on the front end, in order to display all the cars and their characteristics, I have a very long time to process this whole. Suppose I have 1000 cars. I go through all the auto cycle
for(i=0;i<1000;i++){
contractAddress.getCarArray(i)….
}
And then I get 1000 calls to the node, which results in a long time loading all the information.
That's the question - Is there any mechanism that will reduce the time to get all the available cars and information about them? Or on the front end side or on the Solidity side?