structs.sol

Overview

This Solidity source file defines several struct data types designed to represent core entities related to message verification, staking mechanisms, and license management within a decentralized system. The structs encapsulate data attributes crucial for tracking the state and properties of messages, stakes, licenses, and locking mechanisms used in the application’s business logic. These data structures provide a foundational layer for contract modules that manage reputation, stake delegation, and license status control.

Detailed Descriptions of Structs

MessageInfo

Represents information about a message including its unique identifier and expiration.

MessageInfo memory msgInfo = MessageInfo({
    messageHash: keccak256(abi.encodePacked(messageData)),
    expireAt: uint32(block.timestamp + 3600) // expires in one hour
});

MessageInfo is typically used for message validation processes where expiration and integrity checks are necessary.


Stake

Captures staking information related to a participant, including sequence numbers and cryptographic keys.

Stake memory newStake = Stake({
    stake: 1000 ether,
    seqNoStart: 1,
    seqNoFinish: 100,
    bls_key: blsPublicKey,
    status: 1,
    signerIndex: 42
});

Stake is fundamental in handling validator or participant stakes, especially in consensus or slashing mechanisms.


LicenseData

Holds detailed license-related information, including reputation, status, privileges, and stake locking parameters.

LicenseData memory license = LicenseData({
    reputationTime: 100000,
    status: 2,
    isPrivileged: true,
    stakeController: optional(addressStakeController),
    last_touch: uint64(block.timestamp),
    balance: 5000 ether,
    lockStake: 1000 ether,
    lockContinue: 500 ether,
    lockCooler: 200 ether,
    isLockToStake: true,
    coolerCount: 3,
    isLockToStakeByWallet: false,
    isLockBecauseOfSlashing: false
});

This struct supports license lifecycle management, reputation tracking, and enforcement of stake-related constraints.


LicenseStake

Represents the numerical identifier and stake amount associated with a license.

LicenseStake memory licStake = LicenseStake({
    num: 12345,
    stake: 2000 ether
});

Used when associating stake data with licenses in accounting or staking modules.


LockStake

Encapsulates stake locking information including the stake value and the finishing timestamp of the lock.

LockStake memory lock = LockStake({
    value: 1000 ether,
    timeStampFinish: uint32(block.timestamp + 86400) // lock expires in 24 hours
});

Critical for enforcing time-based restrictions on stake withdrawals or transfers.


Implementation Details and Algorithms

Interaction with Other Parts of the System

Visual Diagram: Struct Relationships and Primary Attributes

classDiagram
class MessageInfo {
+uint256 messageHash
+uint32 expireAt
}
class Stake {
+uint256 stake
+uint64 seqNoStart
+uint64 seqNoFinish
+bytes bls_key
+uint8 status
+uint16 signerIndex
}
class LicenseData {
+uint128 reputationTime
+uint8 status
+bool isPrivileged
+optional(address) stakeController
+uint64 last_touch
+uint128 balance
+uint128 lockStake
+uint128 lockContinue
+uint128 lockCooler
+bool isLockToStake
+uint32 coolerCount
+bool isLockToStakeByWallet
+bool isLockBecauseOfSlashing
}
class LicenseStake {
+uint256 num
+uint128 stake
}
class LockStake {
+uint256 value
+uint32 timeStampFinish
}

This diagram illustrates the main structs within the file with their key properties, emphasizing their role as data carriers in the staking and licensing domain.


For further understanding of topics like staking mechanisms, licensing models, and cryptographic key handling, refer to the relevant Staking Fundamentals, License Management, and Cryptography documentation.