cred

package
v0.0.0-...-1fe6bf9 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cred provides a wrapper around the go-redis client

Index

Constants

This section is empty.

Variables

View Source
var NewRoundScript = redis.NewScript(`
local base_key = ARGV[1]
local block_height = ARGV[2]
local round = ARGV[3]
local step = ARGV[4]
local proposer = ARGV[5]
local proposer_index = ARGV[6]

-- Generate the sequence key based on the base key and block height
local sequence_key = base_key .. ":sequence_round:" .. block_height

-- Increment the sequence counter
local sequence = redis.call("INCR", sequence_key)

-- Construct the ID
local id = block_height .. "-" .. sequence

-- Add entry to the stream
redis.call("XADD", base_key .. ":new_round", id, 
           "round", round, 
           "step", step, 
           "proposer", proposer, 
           "proposer_index", proposer_index)

return id
`)
View Source
var NewRoundStepScript = redis.NewScript(`
local base_key = ARGV[1]
local block_height = ARGV[2]
local round = ARGV[3]
local step = ARGV[4]

-- Generate the sequence key based on the base key and block height
local sequence_key = base_key .. ":sequence_round_step:" .. block_height

-- Increment the sequence counter
local sequence = redis.call("INCR", sequence_key)

-- Construct the ID
local id = block_height .. "-" .. sequence

-- Add entry to the stream
redis.call("XADD", base_key .. ":new_round_step", id, "round", round, "step", step)

return id
`)
View Source
var VotesLuaScript = redis.NewScript(`
local base_key = ARGV[1]
local block_height = ARGV[2]
local validator = ARGV[3]
local round = ARGV[4]
local signature = ARGV[5]
local index = ARGV[6]
local block_hash = ARGV[7]
local vote_type = ARGV[8]
local timestamp = ARGV[9]

-- Generate the sequence key based on the base key and block height
local sequence_key = base_key .. ":sequence_vote:" .. block_height

-- Increment the sequence counter
local sequence = redis.call("INCR", sequence_key)

-- Construct the ID
local id = block_height .. "-" .. sequence

-- Add entry to the stream
redis.call("XADD", base_key .. ":votes", id, "validator", validator, "round", round, "signature", signature, "index", index, "block_hash", block_hash, "type", vote_type, "timestamp", timestamp)

return id
`)

Functions

This section is empty.

Types

type CredClient

type CredClient struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, url string, unsafe bool) (*CredClient, error)

create a new CredClient, if unsafe is true allows running the flushdb command

func (*CredClient) FlushAll

func (c *CredClient) FlushAll(ctx context.Context) error

func (*CredClient) Redis

func (c *CredClient) Redis() *redis.Client

func (*CredClient) StoreNewRound

func (c *CredClient) StoreNewRound(ctx context.Context, network string, roundInfo types.EventDataNewRound) error

func (*CredClient) StoreNewRoundStep

func (c *CredClient) StoreNewRoundStep(ctx context.Context, network string, roundInfo types.EventDataRoundState) error

func (*CredClient) StoreVote

func (c *CredClient) StoreVote(ctx context.Context, network string, voteInfo types.EventDataVote) error

Jump to

Keyboard shortcuts

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