validatorpass_tracker

package
v0.0.0-...-37a8622 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: GPL-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEventSignature

func GetEventSignature(eventString string) string

Get the event signature of an event, eg. "Redeemed(uint256,bytes32)" If passed a string starting with 0x, it will assume this is the event signature and simply reflect it.

func ProgressUpdate

func ProgressUpdate(startBlock int, currentBlock int, toBlock int, lastUpdate *int)

Verbose function for printing the progress of the search

func VerifyAddress

func VerifyAddress(cometBftAddress string, trackerIns *Tracker) bool

Mapped search for cometBFT callback to account for re-redeems.

func VerifyMembershipOfAddress

func VerifyMembershipOfAddress(cometBftAddress string, trackerIns *Tracker) (determination bool)

CometBFT callback without requiring tokenId, to determine validity of cometbft address in terms of existence of an on-chain redeem event. This function should be called before the validator tries to initiate a join transaction to the network.

func VerifyValidatorAddress

func VerifyValidatorAddress(cometBftAddress string, tokenId string, trackerIns *Tracker) (determination bool)

Types

type RedeemEventRpc

type RedeemEventRpc struct {
	Address          string   `json:"address"`
	Topics           []string `json:"topics"`
	Data             string   `json:"data"`
	BlockNumber      string   `json:"blockNumber"`
	TransactionHash  string   `json:"transactionHash"`
	TransactionIndex string   `json:"transactionIndex"`
	BlockHash        string   `json:"blockHash"`
	LogIndex         string   `json:"logIndex"`
	Removed          bool     `json:"removed"`
}

type Rpc_RedeemEvent

type Rpc_RedeemEvent struct {
	EventSignature string // Redeemed(uint256,bytes32)
	// contains filtered or unexported fields
}

RPC Redeem events that we are interested in and what contract they are associated to.

func NewRedeemEvent

func NewRedeemEvent(event string, contractAddress string, deployBlock int) Rpc_RedeemEvent

Function for initialising the ethereum events you are interested in tracking, requires event, contract address and deploy block. Pass the event in format: function(datatype1,datatype2) eg. "Redeemed(uint256,bytes32)" This function mainly serves to create the input required for rpc interaction or to create a new tracker object.

type Tracker

type Tracker struct {
	RpcAddress string

	TrackedEvent      Rpc_RedeemEvent
	ValidatorList     []Validator_RedeemEvent
	LastTrackerHeight int

	Startsig chan string
	// contains filtered or unexported fields
}

The tracker will keep a list of validator pass redeem events.

func NewTracker

func NewTracker(rpcSourceAddress string, rpcSearchLimit int, TrackedEvent Rpc_RedeemEvent) *Tracker

Create a new tracker object to track an evenblt.

func (*Tracker) AddToAddressMap

func (nft_tracker *Tracker) AddToAddressMap(validatorRedeem Validator_RedeemEvent)

func (*Tracker) AddToTokenIdMap

func (nft_tracker *Tracker) AddToTokenIdMap(validatorRedeem Validator_RedeemEvent)

func (*Tracker) FetchAppendRedeems

func (nft_tracker *Tracker) FetchAppendRedeems(fromBlock int, toBlock int) ([]Validator_RedeemEvent, error)

func (*Tracker) FindRedeems

func (nft_tracker *Tracker) FindRedeems(fromBlock int, toBlock int) (int, error)

Used to make many ethereum remote procedure calls over time to handle limits from rpc provider. Setting a maxBlockSearch of 0 will assume that you have unlimited RPC access, eg. lite or full node locally hosted.

func (*Tracker) StartTracking

func (nft_tracker *Tracker) StartTracking(ctx context.Context, interval time.Duration, confirmations int) (errChannel chan error)

Start tracking redeem events from a Validator Pass smart contract address, you should be able to deterministically call validateNFTMembership() for peer validation in a CometBFT callback.

type Validator_RedeemEvent

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

func FetchRedeemEventsRPC

func FetchRedeemEventsRPC(rpcSource string, TrackedEvent Rpc_RedeemEvent, fromBlock int, toBlock int) ([]Validator_RedeemEvent, error)

Fetch a full list of Validator Passes from a smart contract address.

func NewValidatorRedeemEvent

func NewValidatorRedeemEvent(tokenId string, validatorAddress string, redeemedBlockHeight string) *Validator_RedeemEvent

Records validator pass redeem events including the redeemed validator address and the the block height at which it was redeemed. All parameters are in form of "0x0000000000000000000000000000000000000000000000000000000000000001" as returned by RPC. redeemedBlockHeight assumes a string response from JSON RPC in form "0xabc".

func UpdateRedeemEvent

func UpdateRedeemEvent(newRedeem Validator_RedeemEvent, redeemList []Validator_RedeemEvent) (updatedList []Validator_RedeemEvent)

REDUNDANT FUNCTION Not used, no purpose unless you need to implement re-redeem functionality for you validator pass.

func (*Validator_RedeemEvent) ToString

func (vRedeem *Validator_RedeemEvent) ToString() string

Jump to

Keyboard shortcuts

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