core

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RelevantTxs []blockchain.Transaction

Functions

func GetActiveDBNodes

func GetActiveDBNodes(relevantTxs []blockchain.Transaction) []string

Step 1: Preprocessing — Compute current DB nodes

func InitCore

func InitCore()

func SelectKNodesFromTimestamp

func SelectKNodesFromTimestamp(timestamp string, activeNodes []string, k int) []string

Step 2: Deterministically select K nodes using timestamp

Types

type Core

type Core struct {
}

func NewCore

func NewCore() *Core

func (*Core) FetchMessages

func (c *Core) FetchMessages(timestamp string) ([]Message, error)

func (*Core) SendMessage

func (c *Core) SendMessage(content string) error

type DatabaseNode

type DatabaseNode struct {
	IP   string
	Port string
}

DatabaseNode represents a database node in the network.

type Message

type Message struct {
	Sender  string `json:"sender"`
	Content string `json:"content"`
}

type MessageResponse

type MessageResponse struct {
	Messages []Message `json:"messages"`
}

type ModCert

type ModCert struct {
	Msg        string
	Timestamp  string
	Signatures []ModSign // Only stores {PublicKey, Signature}
}

ModCert aggregates valid moderator signatures.

func SendToModerators

func SendToModerators(msg string, timestamp string) (ModCert, error)

SendToModerators sends a message to moderators and collects signatures.

type ModSign

type ModSign struct {
	Sign      string `json:"sign"`
	PublicKey string `json:"public_key"`
}

ModSign represents a moderator's signature response.

type Moderator

type Moderator struct {
	IP        string
	Port      string
	PublicKey string
}

Moderator represents a moderator node.

func FetchModerators

func FetchModerators() []Moderator

FetchModerators simulates retrieving moderator details. TODO: Replace with real blockchain data fetching.

type MsgCert

type MsgCert struct {
	Sender  string    `json:"sender"`
	Msg     string    `json:"msg"`
	TS      string    `json:"ts"`
	ModCert []ModSign `json:"mod_cert"`
	Sign    string    `json:"sign"`
}

type UserMessage

type UserMessage struct {
	Content   string `json:"content"`
	Timestamp string `json:"timestamp"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL