DrawBuffer

The DrawBuffer provides historical lookups of Draws via a circular ring buffer. Historical Draws can be accessed on-chain using a Draw ID to calculate ring buffer storage slots. The Draw settings can be created by manager/owner and existing Draws can only be updated by the owner. Once a starting Draw has been added to the ring buffer, all following draws must have a sequential Draw ID.

A DrawBuffer stores a limited number of Draws before beginning to overwrite (managed via the cardinality) previous Draws. Mainnet DrawBuffer is updated directly from a DrawBeacon.

Write methods description

initialize()

Allows to initialize the contract during the deployment.

Parameters:

markDrawAsPaid()

Mark a draw as paid. It means that the winners of the draw were paid and the draw can not be paid again.

Parameters:

pushDraw()

Push draw onto draws ring buffer history. Push new draw onto draws history via authorized manager or owner.

Parameters:

setDraw()

Set existing draw in draws ring buffer with new parameters. Push new draw onto draws history via authorized manager or owner.

Parameters:

Return:

setPrizeDistributor()

Set a new PrizeDistributor contract address.

Parameters:

claimOwnership()

Allows the pendingOwner address to claim the owner role. This function is only callable by the pendingOwner.

renounceOwnership()

Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership()

Transfers ownership of the contract to a _pendingOwner. Can only be called by the current owner.

Parameters:

setManager()

Allows the owner to give the manager role to an address. The manager role has access to the functions with the modified onlyManager or onlyManagerOrOwner.

Parameters:

Read methods description

MAX_CARDINALITY()

Ring buffer max length.

getBufferCardinality()

Read a ring buffer cardinality.

getDraw()

Read a draw from the draws ring buffer. Read a draw using the draw.drawId to calculate position in the draws ring buffer.

Parameters:

getDrawCount()

Gets the number of draws held in the draw ring buffer. If no draws have been pushed, it will return 0. If the ring buffer is full, it will return the cardinality. Otherwise, it will return the newest draw index + 1.

Return:

getDraws()

Read multiple draws from the draws ring buffer. Read multiple draws using each draw.drawId to calculate position in the draws ring buffer.

Parameters:

Return:

getNewestDraw()

Read newest draw from draws ring buffer. Uses the nextDrawIndex to calculate the most recently added draw.

getOldestDraw()

Read oldest draw from draws ring buffer. Finds the oldest draw by comparing and/or diffing totalDraws with the cardinality.

getPrizeDistributor()

Read a PrizeDistributor contract address.

owner()

Owner role that can be granted exclusive access to specific functions with the modifier onlyOwner.

manager()

Manager role that can be granted exclusive access to specific functions with the modifier onlyManager or onlyManagerOrOwner.

pendingOwner()

Address that can claim the owner role. It is used to transfer the owner.

Last updated