client

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 18 Imported by: 1

README

Epic Go Client

Go (golang) client for Epic Ledger

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// The latency in milliseconds
	MLatencyMs = stats.Float64("tx/submit/latency", "The latency in milliseconds per submit", "ms")

	// Counts/groups the lengths of lines read in.
	MLineLengths = stats.Int64("tx/submit/abc", "The distribution of line lengths", "By")
)
View Source
var (
	KeyMethod, _ = tag.NewKey("method")
	KeyStatus, _ = tag.NewKey("status")
	KeyError, _  = tag.NewKey("error")
)
View Source
var (
	LatencyView = &view.View{
		Name:        "demo/latency",
		Measure:     MLatencyMs,
		Description: "The distribution of the latencies",

		Aggregation: view.Distribution(0, 25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000),
		TagKeys:     []tag.Key{KeyMethod}}
)

Functions

func EncodeKey

func EncodeKey(k []byte) string

func GenerateKey

func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, error)

func GenerateKeyEncoded

func GenerateKeyEncoded() (string, string, error)

GenerateKeyEncoded returns public key, private key, error

func GetObjectByHash

func GetObjectByHash(ctx context.Context, rpcURL, hash string, dst interface{}) error

GetObjectByHash this gets an object by it's content hash. Very similar to IPFS.

func GetObjectBytesByHash

func GetObjectBytesByHash(ctx context.Context, rpcURL, hash string) ([]byte, error)

GetObjectByHash this gets an object by it's content hash. Very similar to IPFS.

func GetState

func GetState(ctx context.Context, rpcURL, address string) (*models.StateMessage, error)

func PrivateKeyFromHashed

func PrivateKeyFromHashed(ctx context.Context, privateKey string) (ed25519.PrivateKey, error)

func PublicKeyFromPrivate

func PublicKeyFromPrivate(ctx context.Context, privateKey string) (string, error)

func Publish

func Publish(ctx context.Context, rpcURL string, msg *models.BroadcastMsg) error

func Sign

func Sign(ctx context.Context, privateKey string, toSign interface{}) (string, error)

func SignWithPK

func SignWithPK(ctx context.Context, pk ed25519.PrivateKey, toSign interface{}) (string, error)

func SubmitTx

func SubmitTx(ctx context.Context, rpcURL, privateKey string, amount decimal.Decimal, to string, fee decimal.Decimal, codeRef string, args []string) (*models.Transaction, error)

SubmitTx ... codeRef is a docker image or wasm reference

func Verify

func Verify(ctx context.Context, publicKey string, jws string) ([]byte, error)

func VerifyTx added in v0.0.3

func VerifyTx(ctx context.Context, jws string) (*models.Transaction, error)

Types

type Client

type Client interface {

	// SendTransaction ...
	SendTransaction(ctx context.Context, t *models.Transaction) error
	// SendRawTransaction sends the signed raw transaction bytes.
	SendRawTransaction(ctx context.Context, tx []byte) error
	// // Call executes a call without submitting a transaction.
	// Call(ctx context.Context, msg CallMsg) ([]byte, error)
	Close()
}

Client is an interface for the web3 RPC API.

func NewClient

func NewClient(url string) (Client, error)

NewClient creates a new client, backed by url (supported schemes "http", "https", "ws" and "wss").

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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