broadcaster

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 17 Imported by: 2

README

broadcaster

img img

Package which simplifies broadcasting messages to decentr blockchain node

Example

import (
    . "github.com/Decentr-net/decentr/testutil"
    communitytypes "github.com/Decentr-net/decentr/x/community/types"
    "github.com/Decentr-net/go-broadcaster"
)

func main() {
	b, err := broadcaster.New(Config{
		KeyringRootDir:     "~/.decentr",
		KeyringBackend:     "test",
		KeyringPromptInput: "",
		NodeURI:            "http://localhost:26657",
		BroadcastMode:      "sync",
		From:               "jack",
		ChainID:            "local",
	})
	if err != nil {
		panic(err)
	}

	if _, err := b.BroadcastMsg(&communitytypes.MsgFollow{
		Owner: b.From(),
		Whom:  NewAccAddress(),
	}, "follow me back"); err != nil {
		panic(err)
	}
}

Documentation

Overview

Package broadcaster contains code for interacting with the decentr blockchain.

Index

Constants

This section is empty.

Variables

View Source
var ErrTxInMempoolCache = errors.New("tx is already in mempool cache")

ErrTxInMempoolCache is returned when tx is already broadcast and exists in mempool cache.

Functions

func New

func New(cfg Config) (*broadcaster, error)

New returns new instance of broadcaster

Types

type Broadcaster

type Broadcaster interface {
	// From returns address of broadcaster.
	From() sdk.AccAddress
	// GetHeight returns current height.
	GetHeight(ctx context.Context) (uint64, error)
	// BroadcastMsg broadcasts alone message.
	BroadcastMsg(msg sdk.Msg, memo string) (*sdk.TxResponse, error)
	// Broadcast broadcasts messages.
	Broadcast(msgs []sdk.Msg, memo string) (*sdk.TxResponse, error)

	// PingContext pings node.
	PingContext(ctx context.Context) error
}

Broadcaster provides functionality to broadcast messages to cosmos based blockchain node.

type Config

type Config struct {
	KeyringRootDir     string
	KeyringBackend     string
	KeyringPromptInput string

	NodeURI       string
	BroadcastMode string

	From    string
	ChainID string

	Fees      sdk.Coins
	Gas       uint64
	GasAdjust float64
}

Config ...

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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