Fabric-Batch-Chaincode (FBC) is a library that enables batch transactions in chaincode without additional trusted systems.

Fabric-Batch-Chaincode

Test GoDoc

Fabric-Batch-Chaincode (FBC) is a library that enables batch transactions in chaincode without additional trusted systems.

Overview

In FBC, one unit of processing is called Msg, and it provides SubmitMsg function to submit it to the ledger, and Commit function to execute the submitted Msgs.

Each function performs the following operations:

  • SubmitMsg(msg: Msg, current_time: int64)

    • SubmitMsg is a function that takes a Msg and timestamp current_time arguments
    • The validity of current_time is explained in Validation for Current Time.
    • Validate that there is no commit after current_time.
    • Msg is stored in association with a key that contains current_time as prefix.
  • Commit(commit_time: int64)

    • Commit is a function that takes a timestamp commit_time argument.
    • The commit_time should be less than the "Current Time Window" described later.
    • Get Msgs between the last committed time and commit_time.
    • Execute these Msgs, and save a commit log with commit_time as key prefix.

It also keeps the following states:

  • last committed time: "lct" => {timestamp}
  • msg: "msg/{timestamp}{TxID}"
  • commit log: "commit/{timestamp}"

Validation for Current Time

In fabric, no timestamp indicates the current time that is agreed between peers. Of course, it can get a current time in the chaincode, but this is based on the local clock and will be a different value for each peer.

FBC defines "Current Time" as a range defined by a parameter TimeGapAllowance based on the local clock of endorser peers.

Correctness

FBC satisfies the following three properties:

(1) All Msgs will eventually be submitted

  • Insert Msg with current_time as key prefix in SubmitMsg
  • Commit can only be performed at a time older than Current Time

The above points guarantee that a Msg will eventually be submitted if a submitter can get a valid current time.

(2) There is no commit log newer than the time of the uncommitted Msg

  • Verify that there is no commit log newer than the current time with GetStateByRange(current_time, ∞)

This will recheck for the existence of the commit logs during the validation phase, and if there is a commit log with a time newer than current_time, the tx that contains the SubmitMsg will fail. Therefore, (2) is guaranteed.

(3) All submitted Msgs will eventually be committed

  • commit_time is always newer than previous commit_time
  • Timestamp of a Msg to be committed is within the range between the previous time and commit_time.

The above points and (2) guarantees (3) under the assumption that an actor performs Commit.

TODO

  • Implement ChaincodeStubInterface for BatchState
  • Design for Msg authentication
  • Enhance integration with fabric-contract-api-go
    • It should be possible to integrate it into an existing chaincode implementation with a few modifications

Maintainers

Owner
Datachain
Solutions for blockchain interoperability
Datachain
Similar Resources

Go Library [DEPRECATED]

Tideland Go Library Description The Tideland Go Library contains a larger set of useful Google Go packages for different purposes. ATTENTION: The cell

Nov 15, 2022

Go library to parse and render Remarkable lines files

Go library to parse and render Remarkable lines files

go-remarkable2pdf Go library to parse and render Remarkable lines files as PDF.

Nov 7, 2022

A modern text indexing library for go

A modern text indexing library for go

bleve modern text indexing in go - blevesearch.com Features Index any go data structure (including JSON) Intelligent defaults backed up by powerful co

Jan 4, 2023

Faker is a Go library that generates fake data for you.

Faker is a Go library that generates fake data for you.

Faker is a Go library that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your p

Jan 7, 2023

character-set conversion library implemented in Go

mahonia character-set conversion library implemented in Go. Mahonia is a character-set conversion library implemented in Go. All data is compiled into

Dec 22, 2022

:book: A Golang library for text processing, including tokenization, part-of-speech tagging, and named-entity extraction.

prose prose is a natural language processing library (English only, at the moment) in pure Go. It supports tokenization, segmentation, part-of-speech

Jan 4, 2023

golang rss/atom generator library

gorilla/feeds feeds is a web feed generator library for generating RSS, Atom and JSON feeds from Go applications. Goals Provide a simple interface to

Dec 26, 2022

An (almost) compliant XPath 1.0 library.

xsel xsel is a library that (almost) implements the XPath 1.0 specification. The non-compliant bits are: xsel does not implement the id function. The

Dec 21, 2022

pdf document generation library

pdf document generation library

gopdf 项目介绍 gopdf 是一个生成 PDF 文档的 Golang 库. 主要有以下的特点: 支持 Unicode 字符 (包括中文, 日语, 朝鲜语, 等等.) 文档内容的自动定位与分页, 减少用户的工作量. 支持图片插入, 支持多种图片格式, PNG, BMP, JPEG, WEBP,

Dec 8, 2022
🧑‍💻 Go XML generator without Structs™

exml ??‍?? Go XML generator without Structs™ Package exml allows XML documents to be generated without the usage of structs or maps. It is not intende

Nov 15, 2022
A general purpose application and library for aligning text.

align A general purpose application that aligns text The focus of this application is to provide a fast, efficient, and useful tool for aligning text.

Sep 27, 2022
A NMEA parser library in pure Go

go-nmea This is a NMEA library for the Go programming language (Golang). Features Parse individual NMEA 0183 sentences Support for sentences with NMEA

Dec 20, 2022
Go library for the TOML language

go-toml Go library for the TOML format. This library supports TOML version v1.0.0-rc.3 Features Go-toml provides the following features for using data

Dec 27, 2022
A Go library to parse and format vCard

go-vcard A Go library to parse and format vCard. Usage f, err := os.Open("cards.vcf") if err != nil { log.Fatal(err) } defer f.Close() dec := vcard.

Dec 26, 2022
A declarative struct-tag-based HTML unmarshaling or scraping package for Go built on top of the goquery library

goq Example import ( "log" "net/http" "astuart.co/goq" ) // Structured representation for github file name table type example struct { Title str

Dec 12, 2022
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.

omniparser Omniparser is a native Golang ETL parser that ingests input data of various formats (CSV, txt, fixed length/width, XML, EDI/X12/EDIFACT, JS

Jan 4, 2023
The Go library for working with delimited separated value (DSV).

Package dsv is a Go library for working with delimited separated value (DSV). NOTE: This package has been deprecated. See https://github.com/shuLhan/s

Sep 15, 2021
Upskirt markdown library bindings for Go

Goskirt Package goskirt provides Go-bindings for the excellent Sundown Markdown parser. (F/K/A Upskirt). To use goskirt, create a new Goskirt-value wi

Oct 23, 2022
Golang HTML to plaintext conversion library

html2text Converts HTML into text of the markdown-flavored variety Introduction Ensure your emails are readable by all! Turns HTML into raw text, usef

Dec 28, 2022