LibTank

Git Source

Functions

create

Create a new tank

function create(bytes32 _podEntity, uint32 _index) internal returns (bytes32 tankEntity);

Parameters

NameTypeDescription
_podEntitybytes32The id of the pod entity
_indexuint32

Returns

NameTypeDescription
tankEntitybytes32The 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

NameTypeDescription
_inletTankEntitiesbytes32[2]The ids of the inlet tank entities
_outletTankEntitybytes32The id of the outlet tank entity
_blocksSinceLastResolutionuint256The number of blocks since the last resolution
_outputProductThe 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

NameTypeDescription
inletTankAmountsInletTankAmount[]The array of structs to search

Returns

NameTypeDescription
<none>InletTankAmountThe 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

NameTypeDescription
_inletActivebool[2]The array of bools indicating if the inlets are active
_inletTankEntitiesbytes32[2]The array of inlet tank entities

Returns

NameTypeDescription
<none>InletTankAmount[]An array of structs of used tanks

Structs

InletTankAmount

struct InletTankAmount {
    uint32 index;
    uint256 amount;
}