database

package
v0.0.0-...-a75425d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *gorm.DB

Functions

func InitDb

func InitDb(new_db *gorm.DB)

func MarkAsMostRecentlySeen

func MarkAsMostRecentlySeen(pollID [32]byte, voterAddress string, commitHash [32]byte)

func SoftDeleteRevealed

func SoftDeleteRevealed(pollID [32]byte, voterAddress string)

func StoreCommitment

func StoreCommitment(c *gin.Context)

Swagger documentation @Summary Store a commitment privately, to ensure it can be revealed at a later date @Description Save a vote and the matching hash commitment to that vote @ID store-commitment @Produce json @Param payload body database.CommitmentBody true "The (about to be) committed vote details data you would like to store" @Router /commitments/ [post] @Success 200 {object} database.Response "Success" @Failure 406 {object} database.Response "Bad payload"

func TestSetupData

func TestSetupData()

Types

type Commitment

type Commitment struct {
	PollID       string
	CreatedAt    time.Time
	VoterAddress string
	CommitHash   string
	VoteOption   uint8
	Salt         uint64
	DeletedAt    *time.Time
	LastOnChain  bool
}

type CommitmentBody

type CommitmentBody struct {
	PollID       string `json:"pollID" example:"0x12345678901234567890123456789012"`
	VoterAddress string `json:"voterAddress" example:"0x11223344556677889900"`
	CommitHash   string `json:"commitHash" example:"0x12345678909876543210123456789012"`
	VoteOption   int64  `json:"voteOption" example:"1"`
	Salt         int64  `json:"salt" example:"5866984321541876564"`
}

type Response

type Response struct {
	Message string `json:"message" example:"vote will be revealed when voting closes"`
}

Jump to

Keyboard shortcuts

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