exonum

package module
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

Basic Client for Exonum Blockchain

A Go library to work with Exonum blockchain .

Will be soon

Changelog

Detailed changes for each release are documented in the CHANGELOG file.

License

Exonum Client is licensed under the Apache License (Version 2.0). See LICENSE for details.

Documentation

Overview

* Copyright (c) 2018 - 2019. The Inn4Science Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	TransactionClass = 0
	TransactionType  = 0
	PreCommitClass   = 1
	PreCommitType    = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	ProposerID uint      `json:"proposer_id"`
	Height     uint64    `json:"height"`
	TxCount    uint64    `json:"tx_count"`
	PrevHash   string    `json:"prev_hash"`
	TxHash     string    `json:"tx_hash"`
	StateHash  string    `json:"state_hash"`
	Time       time.Time `json:"time"`
}

type BlocksResponse

type BlocksResponse struct {
	Range struct {
		Start int `json:"start"`
		End   int `json:"end"`
	} `json:"range"`
	Blocks []Block `json:"blocks"`
}

type ExplorerApi

type ExplorerApi interface {
	New(baseURL URL) ExplorerApi
	SetURL(url URL) ExplorerApi
	SetHeader(header string, value string) ExplorerApi

	SystemPath(prefix string) *URL
	ExplorerPath(prefix string) *URL
	ServicePath(serviceName, prefix string) *URL

	Stats() (*Stats, ExplorerApiError)
	Services() (*ServiceList, ExplorerApiError)
	HealthCheck() (*HealthCheck, ExplorerApiError)

	GetBlocks(count uint32, latest uint64, skipEmptyBlocks bool, addTime bool) (*BlocksResponse, ExplorerApiError)
	GetBlock(height uint64) (*FullBlock, ExplorerApiError)
	LastBlock() (*FullBlock, ExplorerApiError)

	GetTx(hash crypto.Hash) (*FullTx, ExplorerApiError)
	SubmitTx(signedTx string) (*TxResult, ExplorerApiError)

	GetJSON(fullURL string, dest interface{}) ExplorerApiError
	PostJSON(fullURL string, body []byte, dest interface{}) ExplorerApiError
}

func NewExplorerApi

func NewExplorerApi(baseURL URL) ExplorerApi

type ExplorerApiError added in v0.5.1

type ExplorerApiError interface {
	Error() string
	StatusCode() int
	Wrap(err error) ExplorerApiError
	Unwrap() error
	AsError() error
}

func NewError added in v0.5.1

func NewError(msg string, statusCode int) ExplorerApiError

func WrapError added in v0.5.1

func WrapError(err error) ExplorerApiError

type FullBlock added in v0.6.0

type FullBlock struct {
	Block
	PreCommits []string     `json:"precommits"`
	Txs        []TxHashInfo `json:"txs"`
	Time       time.Time    `json:"time"`
}

type FullTx

type FullTx struct {
	Type    string `json:"type"`
	Content struct {
		Debug   json.RawMessage `json:"debug"`
		Message string          `json:"message"`
	} `json:"content"`
	Location struct {
		BlockHeight     int `json:"block_height"`
		PositionInBlock int `json:"position_in_block"`
	} `json:"location"`
	LocationProof struct {
		Val string `json:"val"`
	} `json:"location_proof"`
	Status struct {
		Type        string `json:"type"`
		Code        int    `json:"code"`
		Description string `json:"description"`
	} `json:"status"`
}

type HealthCheck added in v0.6.0

type HealthCheck struct {
	ConsensusStatus string `json:"consensus_status"`
	ConnectedPeers  uint   `json:"connected_peers"`
}

type Message

type Message struct {
	Schema      Schema
	Author      crypto.PublicKey
	Class       uint8
	MessageType uint8
}

type Schema

type Schema interface {
	Reset()
	String() string
	ProtoMessage()
	Descriptor() ([]byte, []int)
}

type ServiceInfo added in v0.6.0

type ServiceInfo struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
}

type ServiceList added in v0.6.0

type ServiceList struct {
	Services []ServiceInfo `json:"services"`
}

type ServiceTx

type ServiceTx struct {
	Message
	ServiceID uint16           `json:"service_id"`
	MessageID uint16           `json:"message_id"`
	Signature crypto.Signature `json:"signature"`
	// contains filtered or unexported fields
}

func (ServiceTx) DecodeSignedTx added in v0.5.2

func (ServiceTx) DecodeSignedTx(rawTx string, schema Schema) (ServiceTx, error)

func (ServiceTx) DecodeSignedWSchemaProvider added in v0.6.1

func (ServiceTx) DecodeSignedWSchemaProvider(rawTx string, provider func(uint16, uint16) (Schema, error)) (ServiceTx, error)

DecodeSignedWSchemaProvider ... SchemaProvider should return Schema implementation based on serviceID and messageID.

func (ServiceTx) Hash

func (tx ServiceTx) Hash() (crypto.Hash, error)

Hash creates SHA256 of `ServiceTx`.

func (*ServiceTx) IntoSignedTx

func (tx *ServiceTx) IntoSignedTx(key crypto.SecretKey) (string, error)

IntoSignedTx signs serialized `ServiceTx` with passed key, attach signature and encode to hex.

func (ServiceTx) New

func (ServiceTx) New(schema Schema, author crypto.PublicKey, serviceID uint16, messageID uint16) ServiceTx

func (*ServiceTx) Serialize

func (tx *ServiceTx) Serialize() ([]byte, error)

func (*ServiceTx) Sign

func (tx *ServiceTx) Sign(key crypto.SecretKey) (crypto.Signature, error)

Sign serialized `ServiceTx` with passed key.

type Stats added in v0.6.0

type Stats struct {
	TxPoolSize  uint `json:"tx_pool_size"`
	TxCount     uint `json:"tx_count"`
	TxCacheSize uint `json:"tx_cache_size"`
}

type TxHashInfo added in v0.6.0

type TxHashInfo struct {
	TxHash    crypto.Hash `json:"tx_hash"`
	ServiceID uint        `json:"service_id"`
}

type TxResult

type TxResult struct {
	TxHash crypto.Hash `json:"tx_hash"`
}

type URL

type URL struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (URL) New

func (URL) New(rawURL string) (URL, error)

func (*URL) SetBasePath

func (j *URL) SetBasePath(path string) *URL

func (*URL) SetPath

func (j *URL) SetPath(path string) *URL

func (*URL) String

func (j *URL) String() string

func (*URL) WithPath

func (j *URL) WithPath(path string) string

func (*URL) WithPathURL

func (j *URL) WithPathURL(path string) url.URL

func (*URL) WithQuery

func (j *URL) WithQuery(values url.Values) string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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