model

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitBlockTable

func InitBlockTable(db *gorm.DB)

func InitEventTable

func InitEventTable(db *gorm.DB)

func InitVoteTable

func InitVoteTable(db *gorm.DB)

Types

type Block

type Block struct {
	Id          int64  `gorm:"NOT NULL"`
	Height      uint64 `gorm:"NOT NULL;uniqueIndex:idx_height"`
	BlockTime   int64  `gorm:"NOT NULL"`
	CreatedTime int64  `gorm:"NOT NULL"`
}

func (*Block) TableName

func (*Block) TableName() string

type Event

type Event struct {
	Id                int64
	ChallengeId       uint64       `gorm:"NOT NULL;uniqueIndex:idx_challenge_id"`
	ObjectId          string       `gorm:"NOT NULL;index:idx_object_id_sp_addr"`
	SegmentIndex      uint32       `gorm:"NOT NULL"`
	SpOperatorAddress string       `gorm:"NOT NULL;index:idx_object_id_sp_addr"`
	RedundancyIndex   int32        `gorm:"NOT NULL"`
	ChallengerAddress string       `gorm:"NOT NULL"`
	Height            uint64       `gorm:"NOT NULL;"`
	Status            EventStatus  `gorm:"NOT NULL;index:idx_status"`
	VerifyResult      VerifyResult `gorm:"NOT NULL;index:idx_verify_result"`
	CreatedTime       int64        `gorm:"NOT NULL"`
	ExpiredHeight     uint64       `gorm:"NOT NULL;index:idx_expired_height"`
}

func (*Event) TableName

func (*Event) TableName() string

type EventStatus

type EventStatus int
const (
	Unprocessed          EventStatus = iota // Event is just stored
	Verified                                // Event has been verified, and verify result is stored in VerifyResult
	SelfVoted                               // Event has been voted locally
	EnoughVotesCollected                    // Event has been voted for more than 2/3 validators
	Submitted
	SelfAttested
	Attested // Event has been submitted for tx
	Duplicated
	DuplicatedSlash
)

type VerifyResult

type VerifyResult int
const (
	Unknown        VerifyResult = iota // Event not been verified
	HashMatched                        // The challenge failed, hashes are matched
	HashMismatched                     // The challenge succeed, hashed are not matched
)

type Vote

type Vote struct {
	Id          int64
	ChallengeId uint64 `gorm:"NOT NULL;index:idx_challenge_id"`
	PubKey      string `gorm:"NOT NULL;uniqueIndex:idx_pubkey_eventhash;size:96"`
	Signature   string `gorm:"NOT NULL;size:192"`
	EventType   uint32 `gorm:"NOT NULL"`
	EventHash   string `gorm:"NOT NULL;uniqueIndex:idx_pubkey_eventhash;size:64"`
	CreatedTime int64  `gorm:"NOT NULL"`
}

func (*Vote) TableName

func (*Vote) TableName() string

Jump to

Keyboard shortcuts

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