types

package
v0.0.0-...-7131e01 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the oracle module
	ModuleName = "oracle"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// QuerierRoute is the querier route for the oracle module
	QuerierRoute = ModuleName

	// RouterKey is the msg router key for the oracle module
	RouterKey = ModuleName
)
View Source
const (
	TestID                     = "oracleID"
	AlternateTestID            = "altOracleID"
	TestString                 = "{value: 5}"
	AlternateTestString        = "{value: 7}"
	AnotherAlternateTestString = "{value: 9}"
)
View Source
const FailedStatusText = "failed"
View Source
const PendingStatusText = "pending"
View Source
const SuccessStatusText = "success"

Variables

This section is empty.

Functions

func ErrDuplicateMessage

func ErrDuplicateMessage(codespace sdk.CodespaceType) sdk.Error

func ErrInternalDB

func ErrInternalDB(codespace sdk.CodespaceType, err error) sdk.Error

func ErrInvalidClaim

func ErrInvalidClaim(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidIdentifier

func ErrInvalidIdentifier(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidValidator

func ErrInvalidValidator(codespace sdk.CodespaceType) sdk.Error

func ErrMinimumConsensusNeededInvalid

func ErrMinimumConsensusNeededInvalid(codespace sdk.CodespaceType) sdk.Error

func ErrNoClaims

func ErrNoClaims(codespace sdk.CodespaceType) sdk.Error

func ErrProphecyFinalized

func ErrProphecyFinalized(codespace sdk.CodespaceType) sdk.Error

func ErrProphecyNotFound

func ErrProphecyNotFound(codespace sdk.CodespaceType) sdk.Error

Types

type CodeType

type CodeType = sdk.CodeType

Local code type

const (
	DefaultCodespace sdk.CodespaceType = "oracle"

	CodeProphecyNotFound              CodeType = 1
	CodeMinimumConsensusNeededInvalid CodeType = 2
	CodeNoClaims                      CodeType = 3
	CodeInvalidIdentifier             CodeType = 4
	CodeProphecyFinalized             CodeType = 5
	CodeDuplicateMessage              CodeType = 6
	CodeInvalidClaim                  CodeType = 7
	CodeInvalidValidator              CodeType = 8
	CodeInternalDB                    CodeType = 9
)

Exported code type numbers

type DBProphecy

type DBProphecy struct {
	ID              string `json:"id"`
	Status          Status `json:"status"`
	ClaimValidators []byte `json:"claim_validators"` //This is a mapping from a claim to the list of validators that made that claim
	ValidatorClaims []byte `json:"validator_claims"` //This is a mapping from a validator bech32 address to their claim
}

DBProphecy is what the prophecy becomes when being saved to the database. Tendermint/Amino does not support maps so we must serialize those variables into bytes.

func (DBProphecy) DeserializeFromDB

func (dbProphecy DBProphecy) DeserializeFromDB() (Prophecy, error)

DeserializeFromDB deserializes a DBProphecy into a prophecy

type Prophecy

type Prophecy struct {
	ID              string                      `json:"id"`
	Status          Status                      `json:"status"`
	ClaimValidators map[string][]sdk.ValAddress `json:"claim_validators"` //This is a mapping from a claim to the list of validators that made that claim
	ValidatorClaims map[string]string           `json:"validator_claims"` //This is a mapping from a validator bech32 address to their claim
}

func NewEmptyProphecy

func NewEmptyProphecy() Prophecy

NewEmptyProphecy returns a blank prophecy, used with errors

func NewProphecy

func NewProphecy(id string) Prophecy

NewProphecy returns a new Prophecy, initialized in pending status with an initial claim

func (Prophecy) AddClaim

func (prophecy Prophecy) AddClaim(validator sdk.ValAddress, claim string)

AddClaim adds a given claim to this prophecy

func (Prophecy) FindHighestClaim

func (prophecy Prophecy) FindHighestClaim(ctx sdk.Context, stakeKeeper staking.Keeper) (string, int64, int64)

func (Prophecy) SerializeForDB

func (prophecy Prophecy) SerializeForDB() (DBProphecy, error)

SerializeForDB serializes a prophecy into a DBProphecy TODO: Using gob here may mean that different tendermint clients in different languages may serialize/store prophecies in their db in different ways - check with @codereviewer if this is ok or if it introduces a risk of creating forks. Or maybe using a slower json serializer or Amino:JSON would be ok

type Status

type Status struct {
	StatusText string `json:"status_text"`
	FinalClaim string `json:"final_claim"`
}

Status is a struct that contains the status of a given prophecy

func NewStatus

func NewStatus(status string, finalClaim string) Status

NewStatus returns a new Status with the given data contained

Jump to

Keyboard shortcuts

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