structs.sol

Overview

This file defines fundamental data structures (structs) used to represent key entities related to message handling and credit configuration in the system. These structs serve as blueprints for grouping related data fields together, enabling efficient storage and manipulation of complex data types within smart contracts or other components that use the GOSH-specific Solidity version (pragma gosh-solidity >=0.76.1).

The file contains two struct definitions:

These structures are typically used in contracts or modules that process messages with expiration constraints and manage credit limits or balances.

Struct Definitions

MessageInfo

struct MessageInfo {
    uint256 messageHash;
    uint32 expireAt;
}
MessageInfo memory msgInfo = MessageInfo({
    messageHash: uint256(keccak256(abi.encodePacked(messageContent))),
    expireAt: uint32(block.timestamp + 3600) // Expires in 1 hour
});

CreditConfig

struct CreditConfig {
    bool is_unlimit;
    int128 available_balance;
}
CreditConfig memory credit = CreditConfig({
    is_unlimit: false,
    available_balance: 1000
});

Implementation Details

Interaction with Other System Components

Diagram: Struct Relationships and Usage Context

classDiagram
class MessageInfo {
+uint256 messageHash
+uint32 expireAt
}
class CreditConfig {
+bool is_unlimit
+int128 available_balance
}
class MessageProcessor {
+validateMessage()
+expireMessage()
}
class CreditManager {
+checkCredit()
+updateBalance()
}
MessageProcessor --> MessageInfo : uses
CreditManager --> CreditConfig : uses

This diagram shows the two structs and their typical usage by higher-level components such as MessageProcessor and CreditManager, which implement logic for message validation and credit management respectively. The arrows indicate dependency and usage relationships.