区块链100讲:用一个案例说明Hyperledger Fabric网络构架

Hyperledger Fabric 1.0 安装和使用 注意:代码路径已更新,可以直接参考 https://github.com/yeasy/docker-compose-files/tree/master/hyperledger_fabric/。Hyperledger Fabric 1.0 版本整体 重新设计了架构,预计将于今年 3 月份发布。目前已经进入了 alpha 阶段,可以进行功能性验证。本文将介绍如何快速启动一个 Fabric 1.0 的网... 阅读详情

image

无论是想专注于Composer开发的,还是自己搭建Fabric网络的,都绕不开Fabric构架这一关。(发现绕过方法的人,请于文末留言,顶礼膜拜~)。本文将通过一个网络组建的实践重点介绍Fabric网络。

1

Fabric网络概要

image

tx: transaction 交易,操作。

比如去超市买狗粮的时候,从自己的电子钱包转帐到咖啡店这个请求,可以看作是一个tx。

比如你收到快递,你通过快递公司的应用,点击了“查收”,这个操作可以看作一个tx。

每次一你准备更新账本的操作,都可以视为tx。

2

智能合约

image

Fabric是做联盟链的。跟公链不同,任何你想对账本的操作,读取,写入,都需要通过 智能合约 才可以发生的。

Hyperledger Fabric smart contracts are written in chaincode and are invoked by an application external to the blockchain when that application needs to interact with the ledger.

所以,在Fabric里,智能合约 = chaincode

chaincode很重要,也很关键了。不懂chaincode就么有办法玩Fabric网络,但chaincode是用Go写的,你需要先回去学习Go语言,怕怕了吧?o(∩∩)o…哈哈,这个部分经过Composer的封装后,可以用JS来写了。比起完全自己写chaincode,用composer的话,可以简化不少流程呢。所以,未来的铲S官写完这篇博文后,就去学JS。

In most cases, chaincode interacts ONLY with the database component of the ledger, the world state (querying it, for example), and NOT the transaction log.

Chaincode can be implemented in several programming languages. The currently supported chaincode language is Go with support for Java and other languages coming in future releases.

3

Blockchain Ledger 账本

细心的童靴应该注意到了 the world state 这个词。这个就是账本的意思么?跟账本是什么关系呢?

image

Ledger

原来,一个账本里面包含了两部分: the world state 和  Blockchain

The world state represents the current values of all ledger states.

简单粗暴的说,就是区块链里面记录的信息,最终的状态,是由 the world state 来储存的。主要用于上面chaincode的快速查询使用。不用反推所有区块链里面的交易真假。百无聊赖的时候,就可以从 Blockchain 来计算一下,得到新的 the world state。目前存储 the world state可以用: an embedded LevelDB 或者 an external CouchDB。

而账本里面的区块链是: 任何操作的记录

The blockchain is a transaction log, structured as interlinked blocks, where each block contains a sequence of transactions, each of which represents a query or update to the world state.

4

小结

智能合约 又叫做 chaincode,所有的对区块链的操作,都需要通过 chaincode。chaincode 目前支持Go语言,对于这个部分的编程,如果使用 Composer 的话,可以简化流程和节约时间。

通过 chaincode ,我们可以查询,读写 Blockchain Ledger,Blockchain Ledger 又叫做账本。由 the world state 和 Blockchain 组成。the world state 主要服务于 chaincode 的查询。而 Blockchain是用于流水线式记录交易。

5

组建最简网络

目标

通过动手启动一个最简单的Hyperledger Fabric网络,来进一步了解Hyperledger Fabric的网络构成。

这里介绍的步骤,以及代码可能不适用于最新Docker Image,我们在这里主要关注网络结构。

这个网络将包含:

  • 两个参与方

  • 每个参与方有两个节点

  • 有一个 排序节点

准备

Prerequisites(http://hyperledger-fabric.readthedocs.io/en/release-1.1/prereqs.html)

Hyperledger Fabric Samples(http://hyperledger-fabric.readthedocs.io/en/release-1.1/samples.html)

我们将会使用: first-network来演示。

开启我们的第一网络

打开目标目录

cd fabric-samples/first-network

在first-network的文件夹下面,有一个包含了我们启动所需要全部步骤(两个参与方,每个参与方维护两个节点,有一个独立的排序节点)的脚本文件 byfn.sh,这个脚本文件附带注解,有兴趣的童靴可以研究一下。

*   查询 byfn.sh的文档

./byfn.sh --help

Usage:   

byfn.sh -m up|down|restart|generate 

Typically, one would first generate the required certificates and 

genesis block, then bring up the network. e.g.: 

   byfn.sh -m generate -c mychannel

    byfn.sh -m up -c mychannel -s couchdb

    byfn.sh -m up -c mychannel -s couchdb -i 
Hyperledger Caliper测试Fabric网络性能 1. 启动一个fabric网络 根据测试需要,在configtx.yaml中设置合适的参数以及排序服务类型。 BatchTimeout: 2s BatchSize: MaxMessageCount: 100 AbsoluteMaxBytes: 99 MB PreferredMaxBytes: 512 KB 启动网络,以test-network为例 cd test-network ./network.sh up createChannel ./ 阅读详情

相关推荐

区块链100篇之fabric的网络搭建(一)

好久没写博客了,今天开始写关于fabric相关的博客,包括网络的搭建,链码的编写以及sdk的封装。 搭建网络 网络的搭建想分为三篇来写,第一篇写网络的搭建(这里是官方fabric-samples的简化版),第二篇是关于yaml文件的编写,第三篇是关于channel以及chaincode的操作脚本的编写。 前期条件 Git, Docker ,Docker-compose , Go 1.c...

jalins的博客 3693

Gromacs文件格式全解析:xtc vs trr vs cpt,哪种更适合你的模拟需求?

本文深入解析Gromacs分子动力学模拟中的三种核心文件格式xtc、trr和cpt,详细对比其技术特性和适用场景。xtc适合存储效率优先的场景,trr保留完整动力学数据,cpt确保模拟精确重启。通过实际配置示例和存储优化技巧,帮助用户根据模拟需求选择最佳格式组合,平衡分析灵活性与存储成本。

weixin_29281941的博客 102

从有限元到实时孪生:Twin Builder静态降阶模型实战指南

本文详细介绍了如何利用Twin Builder构建静态降阶模型(Static ROM),实现从有限元分析到实时数字孪生的技术跃迁。通过实战案例展示了参数化采样、模型训练和FMU导出的完整流程,帮助工程师将仿真速度提升数百倍,适用于机械臂、汽车悬架等结构静力学分析场景。

weixin_28725949的博客 439

CosyVoice 本地部署详细教程 手把手小白教程

本文提供了详细的CosyVoice本地部署教程,强调了避免中文名称和空格的重要性,并列出了必要的软件安装步骤,包括CUDA、cuDNN、Git和Miniconda。教程涵盖了从检查CUDA版本到下载模型和运行模型的全过程,确保用户能够顺利部署并使用CosyVoice。

huazn612的博客 2万+

【Python 实战基础】如何绘制热力图来模拟绘制北京景区热度图

Python如何绘制热力图来模拟绘制北京景区热度图 文件读写 基础语法 字符串处理 文件生成 数据构建

菜鸟实战的博客 3410

cs188Inference in Bayes Nets(贝叶斯网络的推理)

cs188Inference in Bayes Nets贝叶斯网络的推理Question1(3 points):Bayes Net StructureQuestion2(1 points):Bayes Net ProbabilitiesQuestion 3(5 points):Join FactorsQuestion4(4 points):EliminateQuestion5(4 points):NormalizeQuestion 6(4 points):Variable EliminationQuesti

weixin_46582817的博客 1684

RK3576 USB3.0 DWC3控制器调试:PHY初始化失败排查指南

DWC3 是 Synopsys 公司推出的 USB3.0/3.1 控制器 IP,支持双角色(DRD)模式,可配置为 Host、Device 或 OTG。

小灰灰的博客 1196

人工智能机器学习基础篇】——深入详解强化学习 基础知识,理解马尔可夫决策过程(MDP)、策略、价值函数等关键概念

人工智能机器学习基础篇】——深入详解强化学习 基础知识,理解马尔可夫决策过程(MDP)、策略、价值函数等关键概念

编程技术探索者,分享C/C++、C#、Java、数据库等开发经验,聚焦实战技巧与AI兴趣,助力编程爱好者成长。 1944

Cursor使用教程:用 Cursor 创建第一个 Java 项目

Cursor是一款基于VS Code的AI编程编辑器,专为开发者设计。安装前需确保JDK 8+、Maven 3.8+等环境配置,支持Windows系统。编辑器提供中文界面选项,可通过扩展市场安装语言包。创建Java项目支持手动和AI提示词两种方式:手动需创建目录结构并编写代码;AI方式则通过自然语言描述快速生成项目框架和代码。标准Java项目包含src/main/java主代码目录、src/test/java测试目录及pom.xml等配置文件。Maven项目中,pom.xml是核心配置文件,管理项目依赖与构

博客 3559

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

上一篇: 区块链100讲:零知识证明算法之zkSNARKs
下一篇: 区块链100讲:带你走进EOS的存储系统
HiBlock区块链社区
博客等级 码龄9年 469粉丝 81原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址