jingtum-lib-go

module
v0.0.0-...-61197bd Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2018 License: Apache-2.0

README

jingtum-lib-go

用于和井通区块链网络进行交互的jingtum-lib-go库。提供简单易用的go语言版的本地调用库。

Source code

  • /src/jingtumLib - 源码文件
  • /src/testLib - 提供所有接口的一个集成测试包
  • docs - jingtum-lib-go 使用文档

开发环境

  • Windows 10
  • go version go1.10.1 windows/amd64

概述

基于ws协议的jingtuml-lib-go库来连接井通区块链网络系统。提供了公共的api来创建两种对象:GET请求的Request对象和POST请求的Transaction对象,然后通过Submi方法提交。

使用示例

  1. 创建 Remote实例。
    remote, err := NewRemote("wss://s.jingtum.com:5020", true)
	if err != nil {
		t.Fatalf("New remote fail : %s", err.Error())
		return
	}
  1. 链接服务
cerr := remote.Connect(func(err error, result interface{}) {
		if err != nil {
			t.Fatalf("New remote fail : %s", err.Error())
			return
		}

		jsonBytes, _ := json.Marshal(result)

		t.Logf("Connect success : %s", jsonBytes)
	})
  1. 通过Remote创建Request或Transaction 实例,调用Submit方法提交请求。下面是请求服务器信息示例:
   req, err := remote.RequestServerInfo()
	if err != nil {
		t.Fatalf("Fail request server info %s", err.Error())
	}
	req.Submit(func(err error, result interface{}) {
		if err != nil {
			t.Fatalf("Fail request server info %s", err.Error())
			return
		}

		jsonByte, _ := json.Marshal(result)
		t.Logf("Success request server info %s", jsonByte)
	})
  1. 关闭链接。
    remote.Disconnect()

Remote

Remote是跟井通底层交互最主要的类,它可以组装交易发送到底层、订阅事件及从底层拉取数据。

Request

Request类主管GET请求,包括获得服务器、账号、挂单、路径等信息。请求时不需要提供密钥,且对所有用户公开。所有的请求是异步的,会提供一个回调函数。可以从回调函数获取错误或者结果。

Transaction

Transaction主管POST请求,包括组装交易和交易参数。请求时需要提供密钥,且交易可以进行本地签名和服务器签名。目前支持服务器签名,本地签名支持主要的交易,还有部分参数不支持。所有的请求是异步的,会提供一个回调函数。每个回调函数包含错误信息和成功后的结果。

Events

您可以监听服务器的事件。

  • 监听系统发生的所有交易事件。
  • 监听最新的账号事件。
  • 监听所有服务器状态更改事件。

Directories

Path Synopsis
src
common/github.com/blog4go
Package blog4go provide an efficient and easy-to-use writers library for logging into files, console or sockets.
Package blog4go provide an efficient and easy-to-use writers library for logging into files, console or sockets.
common/goMath
** 产出随机数 *** random.go *** 主要用于产生随机数 *** author: 1416205324@qq.com *** last_modified_time: 2018-5-25 13:13:23 ** 产出随机数 *** random.go *** 主要用于产生随机数 *** author: 1416205324@qq.com *** last_modified_time: 2018-5-25 13:13:23
** 产出随机数 *** random.go *** 主要用于产生随机数 *** author: 1416205324@qq.com *** last_modified_time: 2018-5-25 13:13:23 ** 产出随机数 *** random.go *** 主要用于产生随机数 *** author: 1416205324@qq.com *** last_modified_time: 2018-5-25 13:13:23
common/golang.org/x/net/bpf
Package bpf implements marshaling and unmarshaling of programs for the Berkeley Packet Filter virtual machine, and provides a Go implementation of the virtual machine.
Package bpf implements marshaling and unmarshaling of programs for the Berkeley Packet Filter virtual machine, and provides a Go implementation of the virtual machine.
common/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
common/golang.org/x/net/context/ctxhttp
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
common/golang.org/x/net/dict
Package dict implements the Dictionary Server Protocol as defined in RFC 2229.
Package dict implements the Dictionary Server Protocol as defined in RFC 2229.
common/golang.org/x/net/dns/dnsmessage
Package dnsmessage provides a mostly RFC 1035 compliant implementation of DNS message packing and unpacking.
Package dnsmessage provides a mostly RFC 1035 compliant implementation of DNS message packing and unpacking.
common/golang.org/x/net/html
Package html implements an HTML5-compliant tokenizer and parser.
Package html implements an HTML5-compliant tokenizer and parser.
common/golang.org/x/net/html/atom
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
common/golang.org/x/net/html/charset
Package charset provides common text encodings for HTML documents.
Package charset provides common text encodings for HTML documents.
common/golang.org/x/net/http/httpguts
Package httpguts provides functions implementing various details of the HTTP specification.
Package httpguts provides functions implementing various details of the HTTP specification.
common/golang.org/x/net/http/httpproxy
Package httpproxy provides support for HTTP proxy determination based on environment variables, as provided by net/http's ProxyFromEnvironment function.
Package httpproxy provides support for HTTP proxy determination based on environment variables, as provided by net/http's ProxyFromEnvironment function.
common/golang.org/x/net/http2
Package http2 implements the HTTP/2 protocol.
Package http2 implements the HTTP/2 protocol.
common/golang.org/x/net/http2/h2i
The h2i command is an interactive HTTP/2 console.
The h2i command is an interactive HTTP/2 console.
common/golang.org/x/net/http2/hpack
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
common/golang.org/x/net/icmp
Package icmp provides basic functions for the manipulation of messages used in the Internet Control Message Protocols, ICMPv4 and ICMPv6.
Package icmp provides basic functions for the manipulation of messages used in the Internet Control Message Protocols, ICMPv4 and ICMPv6.
common/golang.org/x/net/idna
Package idna implements IDNA2008 using the compatibility processing defined by UTS (Unicode Technical Standard) #46, which defines a standard to deal with the transition from IDNA2003.
Package idna implements IDNA2008 using the compatibility processing defined by UTS (Unicode Technical Standard) #46, which defines a standard to deal with the transition from IDNA2003.
common/golang.org/x/net/internal/iana
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
common/golang.org/x/net/internal/nettest
Package nettest provides utilities for network testing.
Package nettest provides utilities for network testing.
common/golang.org/x/net/internal/socket
Package socket provides a portable interface for socket system calls.
Package socket provides a portable interface for socket system calls.
common/golang.org/x/net/internal/socks
Package socks provides a SOCKS version 5 client implementation.
Package socks provides a SOCKS version 5 client implementation.
common/golang.org/x/net/internal/sockstest
Package sockstest provides utilities for SOCKS testing.
Package sockstest provides utilities for SOCKS testing.
common/golang.org/x/net/internal/timeseries
Package timeseries implements a time series structure for stats collection.
Package timeseries implements a time series structure for stats collection.
common/golang.org/x/net/ipv4
Package ipv4 implements IP-level socket options for the Internet Protocol version 4.
Package ipv4 implements IP-level socket options for the Internet Protocol version 4.
common/golang.org/x/net/ipv6
Package ipv6 implements IP-level socket options for the Internet Protocol version 6.
Package ipv6 implements IP-level socket options for the Internet Protocol version 6.
common/golang.org/x/net/nettest
Package nettest provides utilities for network testing.
Package nettest provides utilities for network testing.
common/golang.org/x/net/netutil
Package netutil provides network utility functions, complementing the more common ones in the net package.
Package netutil provides network utility functions, complementing the more common ones in the net package.
common/golang.org/x/net/proxy
Package proxy provides support for a variety of protocols to proxy network data.
Package proxy provides support for a variety of protocols to proxy network data.
common/golang.org/x/net/publicsuffix
Package publicsuffix provides a public suffix list based on data from http://publicsuffix.org/.
Package publicsuffix provides a public suffix list based on data from http://publicsuffix.org/.
common/golang.org/x/net/route
Package route provides basic functions for the manipulation of packet routing facilities on BSD variants.
Package route provides basic functions for the manipulation of packet routing facilities on BSD variants.
common/golang.org/x/net/trace
Package trace implements tracing of requests and long-lived objects.
Package trace implements tracing of requests and long-lived objects.
common/golang.org/x/net/webdav
Package webdav provides a WebDAV server implementation.
Package webdav provides a WebDAV server implementation.
common/golang.org/x/net/webdav/internal/xml
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
common/golang.org/x/net/websocket
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.
common/golang.org/x/net/xsrftoken
Package xsrftoken provides methods for generating and validating secure XSRF tokens.
Package xsrftoken provides methods for generating and validating secure XSRF tokens.
jingtumLib
Package jingtumlib Request类主管GET请求,包括获得服务器、账号、挂单、路径等信息。
Package jingtumlib Request类主管GET请求,包括获得服务器、账号、挂单、路径等信息。
jingtumLib/constant
* * 常量类。
* * 常量类。
jingtumLib/utils
* * Hash 工具类.
* * Hash 工具类.

Jump to

Keyboard shortcuts

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