oracle

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultOracleServerAddress = "http://localhost:3030"
View Source
const Register = "register"
View Source
const Unregister = "unregister"
View Source
const Validate = "validatemap"
View Source
const ValidateSingle = "validate"

Variables

ServerAddress is the oracle server we're using

Functions

func NewHareOracleFromClient

func NewHareOracleFromClient(oc *OracleClient) *hareOracle

func NewLocalOracle

func NewLocalOracle(rolacle *eligibility.FixedRolacle, committeeSize int, nodeID types.NodeId) *localOracle

func SetServerAddress

func SetServerAddress(addr string)

Types

type ActivationDb

type ActivationDb interface {
	GetNodeAtxIdForEpoch(nodeId types.NodeId, targetEpoch types.EpochId) (types.AtxId, error)
	GetAtxHeader(id types.AtxId) (*types.ActivationTxHeader, error)
	GetIdentity(edId string) (types.NodeId, error)
}

type BlockEligibilityValidator

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

func NewBlockEligibilityValidator

func NewBlockEligibilityValidator(committeeSize, genesisActiveSetSize uint32, layersPerEpoch uint16, activationDb ActivationDb,
	beaconProvider *EpochBeaconProvider, validateVRF VRFValidationFunction, log log.Log) *BlockEligibilityValidator

func (BlockEligibilityValidator) BlockSignedAndEligible

func (v BlockEligibilityValidator) BlockSignedAndEligible(block *types.Block) (bool, error)

type BlockOracle

type BlockOracle interface {
	BlockEligible(layerID types.LayerID) (types.AtxId, []types.BlockEligibilityProof, error)
}

type EpochBeaconProvider

type EpochBeaconProvider struct {
}

func (*EpochBeaconProvider) GetBeacon

func (p *EpochBeaconProvider) GetBeacon(epochNumber types.EpochId) []byte

type HTTPRequester

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

func NewHTTPRequester

func NewHTTPRequester(url string) *HTTPRequester

func (*HTTPRequester) Get

func (hr *HTTPRequester) Get(api, data string) []byte

type HareOracle

type HareOracle interface {
	Eligible(instanceID uint32, committeeSize int, pubKey string, proof []byte) bool
}

type MinerBlockOracle

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

func NewMinerBlockOracle

func NewMinerBlockOracle(committeeSize uint32, genesisActiveSetSize uint32, layersPerEpoch uint16, activationDb ActivationDb, beaconProvider *EpochBeaconProvider, vrfSigner Signer, nodeId types.NodeId, isSynced func() bool, log log.Log) *MinerBlockOracle

func (*MinerBlockOracle) BlockEligible

func (bo *MinerBlockOracle) BlockEligible(layerID types.LayerID) (types.AtxId, []types.BlockEligibilityProof, error)

func (*MinerBlockOracle) GetEligibleLayers

func (bo *MinerBlockOracle) GetEligibleLayers() []types.LayerID

type OracleClient

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

OracleClient is a temporary replacement fot the real oracle. its gets accurate results from a server.

func NewOracleClient

func NewOracleClient() *OracleClient

NewOracleClient creates a new client to query the oracle. it generates a random worldid

func NewOracleClientWithWorldID

func NewOracleClientWithWorldID(world uint64) *OracleClient

NewOracleClientWithWorldID creates a new client with a specific worldid

func (*OracleClient) Eligible

func (oc *OracleClient) Eligible(layer types.LayerID, round int32, committeeSize int, id types.NodeId, sig []byte) (bool, error)

Eligible checks whether a given ID is in the eligible list or not. it fetches the list once and gives answers locally after that.

func (*OracleClient) IsIdentityActive

func (oc *OracleClient) IsIdentityActive(s string, id types.LayerID) (bool, error)

func (*OracleClient) Proof

func (o *OracleClient) Proof(layer types.LayerID, round int32) ([]byte, error)

func (*OracleClient) Register

func (oc *OracleClient) Register(honest bool, id string)

Register asks the oracle server to add this node to the active set

func (*OracleClient) Unregister

func (oc *OracleClient) Unregister(honest bool, id string)

Unregister asks the oracle server to de-list this node from the active set

func (*OracleClient) ValidateSingle

func (oc *OracleClient) ValidateSingle(instanceID []byte, K int, committeeSize int, proof []byte, pubKey string) bool

NOTE: this is old code, the new Validate fetches the whole map at once instead of requesting for each ID

func (*OracleClient) World

func (oc *OracleClient) World() uint64

World returns the world this oracle works in

type Requester

type Requester interface {
	Get(api, data string) []byte
}

type Signer

type Signer interface {
	Sign(msg []byte) ([]byte, error)
}

type VRFValidationFunction

type VRFValidationFunction func(message, signature, publicKey []byte) (bool, error)

Jump to

Keyboard shortcuts

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