Consumer Registry

Introduction

This document represents the specification of the registry of consumers utilizing Marlin Core network

Data Structures

Type Aliases

Name Type Description Example
CONSUMER_STAKE uint256 Stake required to register as a consumer

Consumer

struct ConsumerData {
    address withdrawalAddress;
    address consumer;
}

Storage

Consumers

mapping(address => ConsumerData) consumers

Events

event ConsumerRegistered(address consumer, address staker, address withdrawalAddress)

ConsumerDeregistered

event ConsumerDeregistered(address consumer, address withdrawalAddress)

Functions

Register

// Staker should send the tx  to ensure that the stake is not misused by someone else after being allocated in LINToken contract
function register(address withdrawalAddress, address consumer) {
    require(LINToken.transferFrom(msg.sender, address(this), CONSUMER_STAKE))
    ConsumerData consumerData = ConsumerData(withdrawalAddress, consumer)
    consumers[consumer] = consumerData
    emit ConsumerRegistered(consumer, msg.sender, withdrawalAddress)
}

Deregister

function deregister() {
    ConsumerData consumerData = consumers[msg.sender]
    require(consumerData.consumer != address(0))
    require(LINToken.transfer(consumerData.withdrawalAddress, CONSUMER_STAKE))
    emit ConsumerDeregistered(msg.sender, withdrawalAddress)
}

GetConsumer

function getConsumer(address consumer) {
    return consumers[consumer]
}

NOTE: Consumers are not slashed, the stake is required to limit sybil attack