wrkchains

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxMRoot     string = "TxMRoot"
	ActionRoot  string = "ActionRoot"
	ProducerSig string = "ProducerSig"
)

nolint

View Source
const (
	ReceiptsRoot string = "ReceiptsRoot"
	TxRoot       string = "TxRoot"
	StateRoot    string = "StateRoot"
	UncleHash    string = "UncleHash"
	MixHash      string = "MixHash"
)

nolint

View Source
const (
	MerkleRoot         string = "MerkleRoot"
	NextConsensus      string = "NextConsensus"
	NextBlockHash      string = "NextBlockHash"
	Nonce              string = "Nonce"
	ScriptInvocation   string = "ScriptInvocation"
	ScriptVerification string = "ScriptVerification"
)

nolint

View Source
const (
	PseudoChainHash1 string = "PseudoChainHash1"
	PseudoChainHash2 string = "PseudoChainHash2"
	PseudoChainHash3 string = "PseudoChainHash3"
)

nolint

View Source
const (
	DataHash           string = "DataHash"
	AppHash            string = "AppHash"
	ValidatorsHash     string = "ValidatorsHash"
	LastResultsHash    string = "LastResultsHash"
	LastCommitHash     string = "LastCommitHash"
	ConsensusHash      string = "ConsensusHash"
	NextValidatorsHash string = "NextValidatorsHash"
	EvidenceHash       string = "EvidenceHash"
)

nolint

View Source
const (
	HeaderXdr string = "HeaderXdr"
)

nolint

Variables

This section is empty.

Functions

func GetDefaultHashMap added in v0.2.2

func GetDefaultHashMap(wrkchainType string, hashRef string) string

GetDefaultHashMap returns the default hash map given a WRKChain type and hash reference (i.e. hash1, hash2 and hash3) It is called during the workoracle init command

func GetSupportedWrkchainTypes added in v0.3.0

func GetSupportedWrkchainTypes() []string

GetSupportedWrkchainTypes returns a slice of currently supported WRKChain types

func IsSupportedHash added in v0.2.2

func IsSupportedHash(wrkchainType string, hashType string) (bool, error)

IsSupportedHash checks if the given hashType for the given chainType is currently supported by WRKOracle

func IsSupportedWrkchainType added in v0.2.2

func IsSupportedWrkchainType(wrkchainType string) bool

IsSupportedWrkchainType checks if the given chainType is currently supported by WRKOracle

Types

type Eos added in v0.3.0

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

Eos is a structure for holding a Eos based WRKChain client

func NewEosClient added in v0.3.0

func NewEosClient(log log.Logger, lastHeight uint64) *Eos

NewEosClient returns a new Eos struct

func (*Eos) GetBlockAtHeight added in v0.3.0

func (n *Eos) GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)

GetBlockAtHeight is used to get the block headers for a given height from a Eos based WRKChain

type EosBlockHeaderResult added in v0.3.0

type EosBlockHeaderResult struct {
	Id          string `json:"id"`        // hash
	BlockNum    uint64 `json:"block_num"` // height
	Previous    string `json:"previous"`  // parent hash
	TxMRoot     string `json:"transaction_mroot"`
	ActionRoot  string `json:"action_mroot"`
	ProducerSig string `json:"producer_signature"`
}

EosBlockHeaderResult holds the result from a Eos JSON RPC query

type EosGetBlockInfoResult added in v0.3.0

type EosGetBlockInfoResult struct {
	ChainId          string `json:"chain_id"`
	LastIrreversible uint64 `json:"last_irreversible_block_num"`
	HeadBlockNum     uint64 `json:"head_block_num"`
}

EosGetBlockInfoResult holds the result for a Eos getbestblockhash JSON RPC query

type Geth added in v0.2.1

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

Geth is a structure for holding a Geth based WRKChain client

func NewGethClient added in v0.2.1

func NewGethClient(log log.Logger, lastHeight uint64) *Geth

NewGethClient returns a new Geth struct

func (*Geth) GetBlockAtHeight added in v0.2.1

func (g *Geth) GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)

GetBlockAtHeight is used to get the block headers for a given height from a geth based WRKChain

type GethBlockHeader added in v0.3.0

type GethBlockHeader struct {
	Number       string `json:"number"`
	Hash         string `json:"hash"`
	ParentHash   string `json:"parentHash"`
	MixHash      string `json:"mixHash"`
	UncleHash    string `json:"sha3Uncles"`
	TxRoot       string `json:"transactionsRoot"`
	StateRoot    string `json:"stateRoot"`
	ReceiptsRoot string `json:"receiptsRoot"`
}

GethBlockHeader holds the minimum Geth block header info returned from a Geth JSON RPC query required to process a geth based WRKChain block header

type GethBlockHeaderResult added in v0.3.0

type GethBlockHeaderResult struct {
	Id      string          `json:"id"`
	Jsonrpc string          `json:"jsonrpc"`
	Result  GethBlockHeader `json:"result"`
}

GethBlockHeaderResult holds the result from a Geth JSON RPC query

type Neo added in v0.3.0

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

Neo is a structure for holding a Neo based WRKChain client

func NewNeoClient added in v0.3.0

func NewNeoClient(log log.Logger, lastHeight uint64) *Neo

NewNeoClient returns a new Neo struct

func (*Neo) GetBlockAtHeight added in v0.3.0

func (n *Neo) GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)

GetBlockAtHeight is used to get the block headers for a given height from a Neo based WRKChain

type NeoBlockHeader added in v0.3.0

type NeoBlockHeader struct {
	Index         uint64 `json:"index"`
	Hash          string `json:"hash"`
	PreviousHash  string `json:"previousblockhash"`
	MerkleRoot    string `json:"merkleroot"`
	NextConsensus string `json:"nextconsensus"`
	NextBlockHash string `json:"nextblockhash"`
	Nonce         string `json:"nonce"`
	Script        struct {
		Invocation   string `json:"invocation"`
		Verification string `json:"verification"`
	} `json:"script"`
}

NeoBlockHeader holds the minimum Neo block header info returned from a Neo JSON RPC query required to process a Neo based WRKChain block header

type NeoBlockHeaderResult added in v0.3.0

type NeoBlockHeaderResult struct {
	Id      int            `json:"id"`
	Jsonrpc string         `json:"jsonrpc"`
	Result  NeoBlockHeader `json:"result"`
}

NeoBlockHeaderResult holds the result from a Neo JSON RPC query

type NeoGetBestBlockResult added in v0.3.0

type NeoGetBestBlockResult struct {
	Id      int    `json:"id"`
	Jsonrpc string `json:"jsonrpc"`
	Result  string `json:"result"`
}

NeoGetBestBlockResult holds the result for a Neo getbestblockhash JSON RPC query

type PseudoChain added in v0.3.0

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

PseudoChain is a structure for holding a PseudoChain WRKChain client

func NewPseudoChainClient added in v0.3.0

func NewPseudoChainClient(log log.Logger, lastHeight uint64) *PseudoChain

NewPseudoChainClient returns a new PseudoChain struct

func (*PseudoChain) GetBlockAtHeight added in v0.3.0

func (d *PseudoChain) GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)

GetBlockAtHeight is used to get the block headers for a given height from a PseudoChain based WRKChain

type Stellar added in v0.3.0

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

Stellar is a structure for holding a Stellar based WRKChain client

func NewStellarClient added in v0.3.0

func NewStellarClient(log log.Logger, lastHeight uint64) *Stellar

NewStellarClient returns a new Stellar struct

func (*Stellar) GetBlockAtHeight added in v0.3.0

func (n *Stellar) GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)

GetBlockAtHeight is used to get the block headers for a given height from a Stellar based WRKChain

type StellarBlockHeader added in v0.3.0

type StellarBlockHeader struct {
	Hash      string `json:"hash"`
	PrevHash  string `json:"prev_hash"`
	Sequence  uint64 `json:"sequence"`
	HeaderXdr string `json:"header_xdr"`
}

StellarBlockHeader holds the minimum Stellar block header info returned from a Stellar JSON RPC query required to process a Stellar based WRKChain block header

type StellarLatestBlockHeader added in v0.3.0

type StellarLatestBlockHeader struct {
	Embedded struct {
		Records []struct {
			StellarBlockHeader
		} `json:"records"`
	} `json:"_embedded"`
}

StellarLatestBlockHeader holds the minimum Stellar block header info returned from a Stellar "latest ledger" JSON RPC query

type Tendermint added in v0.2.1

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

Tendermint is a structure for holding a Tendermint based WRKChain client

func NewTendermintClient added in v0.2.1

func NewTendermintClient(log log.Logger, lastHeight uint64) *Tendermint

NewTendermintClient returns a new Tendermint struct

func (*Tendermint) GetBlockAtHeight added in v0.2.1

func (t *Tendermint) GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)

GetBlockAtHeight is used to get the block headers for a given height from a tendermint based WRKChain

type TmBlock added in v0.3.0

type TmBlock struct {
	Header TmBlockHeader `json:"header"`
}

TmBlock holds the minimum amount of block ID data returned from a Tendermint node RPC request

type TmBlockHeader added in v0.3.0

type TmBlockHeader struct {
	// prev block info
	LastBlockId TmBlockID `json:"last_block_id"`

	Height  string `json:"height"`
	ChainId string `json:"chain_id"`

	// hashes of block data
	LastCommitHash string `json:"last_commit_hash"` // commit from validators from the last block
	DataHash       string `json:"data_hash"`        // transactions

	// hashes from the app output from the prev block
	ValidatorsHash     string `json:"validators_hash"`      // validators for the current block
	NextValidatorsHash string `json:"next_validators_hash"` // validators for the next block
	ConsensusHash      string `json:"consensus_hash"`       // consensus params for current block
	AppHash            string `json:"app_hash"`             // state after txs from the previous block
	// root hash of all results from the txs from the previous block
	LastResultsHash string `json:"last_results_hash"`
	// consensus info
	EvidenceHash string `json:"evidence_hash"` // evidence included in the block
}

TmBlockHeader holds the minimum Tendermint block header info returned from a TM RPC query required to process a geth based WRKChain block header

type TmBlockHeaderResult added in v0.3.0

type TmBlockHeaderResult struct {
	Result TmResult `json:"result"`
}

TmBlockHeaderResult holds the result from a Tendermint node RPC query

type TmBlockID added in v0.3.0

type TmBlockID struct {
	Hash string `json:"hash"`
}

TmBlockID holds the minimum amount of block ID data returned from a Tendermint node RPC request

type TmResult added in v0.3.0

type TmResult struct {
	BlockID TmBlockID `json:"block_id"`
	Block   TmBlock   `json:"block"`
}

TmResult holds the minimum amount of data returned from a Tendermint node RPC request

type WrkChain added in v0.2.1

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

WrkChain is a top level struct to hold WRKChain data

func NewWrkChain added in v0.2.1

func NewWrkChain(wrkchainMeta WrkChainMeta, log log.Logger) (*WrkChain, error)

NewWrkChain returns a new initialised WrkChain

func (*WrkChain) GetLatestBlock added in v0.2.1

func (w *WrkChain) GetLatestBlock() (WrkChainBlockHeader, error)

GetLatestBlock is a top level function to query any WRKChain type for the latest block header

func (*WrkChain) GetWrkChainBlock added in v0.2.1

func (w *WrkChain) GetWrkChainBlock(height uint64) (WrkChainBlockHeader, error)

GetWrkChainBlock is a top level function to query any WRKChain type for the block header at a given height

type WrkChainBlockHeader added in v0.2.2

type WrkChainBlockHeader struct {
	Height     uint64 `json:"height"`
	BlockHash  string `json:"blockhash"`
	ParentHash string `json:"parenthash"`
	Hash1      string `json:"hash1"`
	Hash2      string `json:"hash2"`
	Hash3      string `json:"hash3"`
}

WrkChainBlockHeader is the standard header object that should be returned by any WRKChain type client

func NewWrkChainBlockHeader added in v0.2.2

func NewWrkChainBlockHeader(
	height uint64,
	blockHash string,
	parentHash string,
	hash1 string,
	hash2 string,
	hash3 string,
) WrkChainBlockHeader

NewWrkChainBlockHeader returns a new initialised WrkChainBlockHeader

type WrkChainClient added in v0.2.1

type WrkChainClient interface {
	GetBlockAtHeight(height uint64) (WrkChainBlockHeader, error)
}

WrkChainClient is a generic interface for all WRKChain clients. New WRKChain client modules should implement this interface

type WrkChainMeta added in v0.2.2

type WrkChainMeta struct {
	WRKChainId string `json:"wrkchain_id"`
	Moniker    string `json:"moniker"`
	Name       string `json:"name"`
	Type       string `json:"type"`
	LastBlock  string `json:"lastblock"`
	NumBlocks  string `json:"num_blocks"`
	RegTime    string `json:"reg_time"`
	Owner      string `json:"owner"`
}

WrkChainMeta is an object to hold WRKChain metadata when queried from Mainchain

type WrkChainMetaQueryResponse added in v0.2.2

type WrkChainMetaQueryResponse struct {
	Height string       `json:"height"`
	Result WrkChainMeta `json:"result"`
}

WrkChainMetaQueryResponse is a structure which holds Mainchain query data specifically for WRKChain metadata

type WrkchainModule added in v0.3.0

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

WrkchainModule is a structure to hold WRKChain module information

type WrkchainType added in v0.3.0

type WrkchainType string

WrkchainType is a string alias to hold supported WRKChain types

const (
	PseudoChainWrkchainType WrkchainType = "pseudochain" //generates random hashes for development only
	GethWrkchainType        WrkchainType = "geth"
	CosmosWrkchainType      WrkchainType = "cosmos"
	TendermintWrkchainType  WrkchainType = "tendermint"
	NeoWrkchainType         WrkchainType = "neo"
	StellarWrkchainType     WrkchainType = "stellar"
	EosWrkchainType         WrkchainType = "eos"
)

Currently supported WRKChain types

Jump to

Keyboard shortcuts

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