Git Product home page Git Product logo

gofab's Introduction

gofab

gofab 基于Fabric SDK 创建的扩展,用于更加便利的从客户端操作Fabric

安装

文档

开始之前,假设你已经获得了一个 Fabric SDK 的实例,可以通过以下示例获取:

// 获得SDK实列
sdk := gofab.SDK("config.yaml")
context := sdk.ChannelContext(channelID, fabsdk.WithUser(user), fabsdk.WithOrg(orgName))

// 获取账本客户端实列
ledgerClient, err := ledger.New(context)
gofab.ErrFinal(err)

// 获取账本信息
cfg, err := ledgerClient.QueryConfig()
gofab.ErrLog(err)

// 通过区块的ID获得一个经过解码后的区块
block,err := gofab.GetBlock(1)
gofab.ErrLog(err)

gofab

通过channelledger获取到的区块信息与交易是经过protobuf编码的,gofab对原方法进行封装 在获得信息后进行解码,并返回相关的标准结构体

  • gofab.SDK()

获得一个fabsdk.FabricSDK实列

  • gofab.GetBlock()

通过区块的ID获得一个经过解码后的区块

  • gofab.GetBlockByHash()

通过区块的 hash 获得一个经过解码后的区块

  • gofab.GetBlocksByTxId()

通过交易ID获得一个经过解码后的区块

  • gofab.GetChannelClient()

获得一个channel.Client实列

  • gofab.GetConfig()

获得区块链网络配置

  • gofab.GetInfo()

获得区块链网络信息

  • gofab.GetTransactionByTxID()

通过交易ID获得一个经过解码后的交易

channel

获取 channel 管道的客户端

gofab.GetChannelClient(<管道ID>,<操作用户名>,<操作节点的组织名称>) *channel.Client

channel.Client支持以下操作:

  • channel.Client.Query()

执行查询

  • channel.Client.Execute()

执行交易类型操作

  • channel.Client.InvokeHandler()

执行交易类型操作

  • channel.Client.RegisterChaincodeEvent()

注册链码事件

  • channel.Client.UnregisterChaincodeEvent()

注销链码事件

ledger

获取ledger客户端

ledger.New(context)

ledger.Client 支持以下操作:

  • ledger.Client.QueryInfo()

获取当前区块链网络信息

  • ledger.Client.QueryBlock()

获取区块信息

  • ledger.Client.QueryConfig()

获取配置信息

  • ledger.Client.QueryBlockByHash()

通过Hash获取交易信息

  • ledger.Client.QueryBlockByTxID()

通过交易ID获取Block信息

  • ledger.Client.QueryTransaction()

通过交易ID获取交易信息

gofab's People

Contributors

yiuked avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

gofab's Issues

a question about "third_party"

作者你好,我在使用您的代码的时候遇到一些问题,想要请教。您在transaction.go中引用的头文件中包含third_party的这一部分为什么找不到相应的代码呢?"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/utils"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.