mobile

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 15 Imported by: 0

README

Build from source

Dependencies

Java JDK, Android NDK, Go mobile tools

$ go get golang.org/x/mobile/cmd/gomobile
$ gomobile init -ndk ~/PATH/TO/ANDROID/NDK

Building android library

To compile Go package as android library execute

$ gomobile bind -v -target=android github.com/mosaicnetworks/babble/src/mobile

Import the Babble Module

Follow Oliver's answer:
https://stackoverflow.com/questions/16682847/how-to-manually-include-external-aar-package-using-new-gradle-android-build-syst

Sometimes, Android Studio says “cannot resolve symbol” even if the project compiles. In this case, do the following:

"File" -> "Invalidate Caches..." -> "Invalidate and Restart"

Documentation

Overview

Package mobile is a wrapper for Babble that can be compiled with gomobile for use in Android and iOS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrivPublKeys

func GetPrivPublKeys() string

GetPrivPublKeys generates a new public key pair and returns it in the following formatted string <public key hex>=!@#@!=<private key hex>.

Types

type CommitHandler

type CommitHandler interface {
	OnCommit(block []byte) (processedBlock []byte)
}

CommitHandler wraps an OnCommit callback. This method will be called by Babble to commit blocks. The blocks are serialized with JSON.

type ExceptionHandler

type ExceptionHandler interface {
	OnException(string)
}

ExceptionHandler wraps an OnException callback

type Node

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

Node is the entry point for using Babble from Java or Objective-C. It is a wrapper around a normal Babble node that works around the limitations of gomobile concerning the exportable types.

func New

func New(
	commitHandler CommitHandler,
	stateChangeHandler StateChangeHandler,
	exceptionHandler ExceptionHandler,
	configDir string,
) *Node

New creates a new mobile node from a set of handlers. The configDir parameter points to the directory where Babble configuration files reside.

func (*Node) GetGenesisPeers added in v0.6.0

func (n *Node) GetGenesisPeers() string

GetGenesisPeers returns the genesis peers.

func (*Node) GetPeers added in v0.4.1

func (n *Node) GetPeers() string

GetPeers returns the current list of peers.

func (*Node) GetPubKey added in v0.8.1

func (n *Node) GetPubKey() string

GetPubKey returns the validator's public key in Hex format.

func (*Node) GetStats added in v0.5.0

func (n *Node) GetStats() string

GetStats returns consensus stats.

func (*Node) Leave added in v0.5.0

func (n *Node) Leave()

Leave instructs the node to leave politely (get removed from validator-set) before shutting down.

func (*Node) Run

func (n *Node) Run(async bool)

Run runs the Babble node.

func (*Node) Shutdown

func (n *Node) Shutdown()

Shutdown shutsdown the node without requesting to be removed from the validator-set

func (*Node) SubmitTx

func (n *Node) SubmitTx(tx []byte)

SubmitTx submits a transaction to Babble for consensus ordering.

type StateChangeHandler added in v0.8.0

type StateChangeHandler interface {
	OnStateChanged(state int32)
}

StateChangeHandler wraps an OnStateChanged callback

Jump to

Keyboard shortcuts

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