Stream Contract

Stream contract represents a video transcode job created by a client. Input video stream is split into chunks. Miners transcode video chunks and submit proof for each chunk of each profile. Validators approve proof submitted by miners.

Constructor

constructor(uint256 _id, address payable client, uint256[] memory profiles) Escrow(client) public

It takes the stream id, address of the client that created the stream and array of profiles requested by client. Stream contract is also an Escrow contract.

Add input chunk ID.

function addInputChunkId(uint256 chunkId, uint256[] memory wattage) public onlyManager

Stream Manager will add more input chunkIds as they become available. Function is called only by the manager. Function requires chunkId which is not already registered from a stream that is alive.

End Stream

function endStream() public onlyManager

Signals that the input stream has ended and no more input chunks are available.

Submit proof

function submitProof(uint256 profile, uint256 chunkId, uint256 proof, uint256 outChunkId) public

Miners use the method to submit proofs & output chunkIds. Proofs of transcoding must be submitted for each input chunk for each each profile.

Emits event ChunkProofSubmited

Validate proof

function validateProof(uint256 profile, uint256 chunkId) public onlyValidator

Validators use the method to validate the first proof available in the queue.

Emits event ChunkProofValidated

Scrap proof

function scrapProof(uint256 profile, uint256 chunkId) public onlyValidator

Validators can scrap the first proof available in the queue if they consider so. This will increment the proofs queue head to point to the next proof. This would result in decrease in miner's reputation.

Emits event ChunkProofScrapped

Has Valid proof

function hasValidProof(uint256 profile, uint256 chunkId) public view returns (bool)

Query whether the chunk has been validated.

Get valid proof

function getValidProof(uint256 profile, uint256 chunkId) public view
returns (address miner,
address validator,
uint256 outputChunkId,
uint256 proof)

Returns the proof of a validated chunk. Requires that the proof has been validated.

Get candidate proof

function getCandidateProof(uint256 profile, uint256 chunkId) public view
returns (address miner,
uint256 outputChunkId,
uint256 proof)

Returns the first proof candidate for validation/scraping. Validators should use this to query the current proof candidate before validating it.

Get proof count

function getProofCount(uint256 profile, uint256 chunkId) public view returns (uint256)

Query proof count for given chunk&profile.

Get proof

function getProof(uint256 profile, uint256 chunkId, uint256 idx) public view
returns (address miner,
uint256 outputChunkId,
uint256 proof)

Returns any proof that has been submitted for the given chunk & profile from the proof queue.

Is Transcoding Done

function isTranscodingDone() public view returns (bool)

Query whether transcoding is done for the given input chunks for all profiles.

Is profile transcoded

function isProfileTranscoded(uint256 profile) public view returns (bool)

Query whether transcoding is done for the given input chunks for given profile.

Get profiles

function getprofiles() public view returns (uint256[] memory)

Query profile hashes; the hashes refer to the index array stored in the manager contract.

Get profile count

function getProfileCount() public view returns (uint256)

Query profile count.

Get In chunks

function getInChunks() public view returns (uint256[] memory)

Query input chunk ids.

Get in chunks count

function getInChunkCount() public view returns (uint256)

Query input chunk count.

Get out chunks

function getOutChunks(uint256 profile) public view returns (uint256[] memory)

Query output chunk ids.

Refund allowed

function refundAllowed() public view returns (bool)

Query if refund is allowed.