LibTank
Functions
create
Create a new tank
function create(bytes32 _podEntity, uint32 _index) internal returns (bytes32 tankEntity);
Parameters
Name | Type | Description |
---|---|---|
_podEntity | bytes32 | The id of the pod entity |
_index | uint32 |
Returns
Name | Type | Description |
---|---|---|
tankEntity | bytes32 | The id of the tank entity |
write
Update tanks based on the result of a network resolution
function write(
bytes32[2] memory _inletTankEntities,
bytes32 _outletTankEntity,
uint256 _blocksSinceLastResolution,
Product memory _output
) internal;
Parameters
Name | Type | Description |
---|---|---|
_inletTankEntities | bytes32[2] | The ids of the inlet tank entities |
_outletTankEntity | bytes32 | The id of the outlet tank entity |
_blocksSinceLastResolution | uint256 | The number of blocks since the last resolution |
_output | Product | The output product of the outlet |
findLowestValue
Find the struct with the lowest amount in an array of structs
function findLowestValue(InletTankAmount[] memory inletTankAmounts) internal pure returns (InletTankAmount memory);
Parameters
Name | Type | Description |
---|---|---|
inletTankAmounts | InletTankAmount[] | The array of structs to search |
Returns
Name | Type | Description |
---|---|---|
<none> | InletTankAmount | The struct with the lowest amount |
getUsedInletTanks
Get tanks that are connected to inlets that contribute to the final output
Based on the flags (_inletActive) set on the outlet product struct
function getUsedInletTanks(bool[2] memory _inletActive, bytes32[2] memory _inletTankEntities)
internal
view
returns (InletTankAmount[] memory);
Parameters
Name | Type | Description |
---|---|---|
_inletActive | bool[2] | The array of bools indicating if the inlets are active |
_inletTankEntities | bytes32[2] | The array of inlet tank entities |
Returns
Name | Type | Description |
---|---|---|
<none> | InletTankAmount[] | An array of structs of used tanks |
Structs
InletTankAmount
struct InletTankAmount {
uint32 index;
uint256 amount;
}