当前位置: 首页 > news >正文

做网站公司名字网站seo优化总结

做网站公司名字,网站seo优化总结,网站为什么需要备案,微信做网站的公司一.检查配置环境 检查虚拟机环境,确保有正在运行的Hyperledger Fabric区块链,并且其中chaincode_basic、credit_chaincode链码可以正常调用 查看chaincode_basic、credit_chaincode链码调用 二.开发征信链码代码 基于现有征信链码,开发征信…

一.检查配置环境

检查虚拟机环境,确保有正在运行的Hyperledger Fabric区块链,并且其中chaincode_basic、credit_chaincode链码可以正常调用

查看chaincode_basic、credit_chaincode链码调用

二.开发征信链码代码 

基于现有征信链码,开发征信链码的升级版,使用chaincode-init文件夹中的基础链码模板,创建完善其中lib目录以及index.js内容,在lib中创建CreditPlusContract对象,在对象中添加createCreditSubjectPlus功能,实现征信主体的保存,定义subject变量属性包括(key:征信主体主键,  organizationName:征信主体评价机构名, type:评价类型,score:征信积分,creator:创建人,datetime:评价时间),其中属性除score外其余都为string类型。将subject内容上链保存  

在链码中添加征信主体查询功能(queryCreditSubjectPlus),要求能够查询所有主体内容(包括:key:征信主体主键,  organizationName:征信主体评价机构名, type:评价类型,score:征信积分,creator:创建人,datetime:评价时间)

'use strict';
const { Contract } = require("fabric-contract-api");
class CreditPlusContract extends Contract {async createCreditSubjectPlus(ctx, key, organizationName, type, creator, datetime) {console.info('=== START:创建征信主体 ===');const subject = {key: key,organizationName: organizationName,type: type,score: 0,creator: creator,datetime: datetime};await ctx.stub.putState(key, Buffer.from(JSON.stringify(subject)));console.info('=== END:创建征信主体 ===');return subject;}// 查询征信主体async queryCreditSubjectPlus(ctx, subjectKey) {console.info('=== START : 查询征信主体 ===');const bytes = await ctx.stub.getState(subjectKey);if (!bytes || bytes.length === 0) {const msg = `${subjectKey} 征信主体不存在`;console.warn(msg);throw new Error(msg);}const subject = JSON.parse(bytes.toString());console.info('=== END : 查询征信主体 ===');return subject;}}module.exports = CreditPlusContract;

 在链码结构中test目录中添加对于createCreditSubjectPlus以及QueryCreditSubjectPlus功能的单元测试,提交测试代码和验证结果。

'use strict';
const sinon = require('sinon');
const chai = require('chai');
const sinonChai = require('sinon-chai');
const expect = chai.expect;
chai.use(sinonChai);
let assert = sinon.assert;
const { Context } = require('fabric-contract-api');
const { ChaincodeStub, ClientIdentity } = require('fabric-shim');
const CreditPlusContract = require('../lib/creditContract');
describe('Credit Chaincode Test', () => {let stub, ctx, ClientId;beforeEach(() => {ctx = new Context();stub = sinon.createStubInstance(ChaincodeStub);stub.getMspID.returns('Org1');ctx.setChaincodeStub(stub);ClientId = sinon.createStubInstance(ClientIdentity);stub.putState.callsFake((key, value) => {if (!stub.states) {stub.states = {};}stub.states[key] = value;});stub.getState.callsFake(async (key) => {let ret;if (stub.states) {ret = stub.states[key];}return Promise.resolve(ret);});stub.deleteState.callsFake(async (key) => {if (stub.states) {delete stub.states[key];}});});describe('Test CreditSubject function', () => {it('should return success on createCreditSubject', async () => {let creditContract = new CreditPlusContract();let creditSubject = await creditContract.createCreditSubjectPlus(ctx, "A001", "My Company", "Company","Admin","2024-05-28 14:35:00");let scroe = creditSubject.score;expect(scroe).to.equals(0);});it('should return success on queryCreditSubject', async () => {let creditContract = new CreditPlusContract();await creditContract.createCreditSubjectPlus(ctx, "A001", "My Company", "Company", "Admin", "2024-05-28 14:35:00");let creditSubject = await creditContract.queryCreditSubjectPlus(ctx, "A001");let name = creditSubject.organizationName;expect(name).to.equals("My Company");});});
})

测试代码:

 

三.部署征信链码

在虚拟机指定Hyperledger Fabric中实现对应链码的部署并验证部署情况。

将链码名修改切credit_chaincode_plus,删除node_modules目录以及对应package-lock.json文件,上传至服务器chaincode目录下:

打包测试:

export FABRIC_CFG_PATH=${PWD}/configpeer lifecycle chaincode package ./chaincode/credit_chaincode_plus.tar.gz --path ./chaincode/credit_chaincode_plus --lang node --label credit_chaincode_plus_1.0

 

查看打包结果:

安装链码:运行以下进入fabric-cli容器:

docker exec -it fabric-cli bash

1. 在org1中安装:运行以下链码安装:

. scripts/set-env.sh 1 0 7051
peer lifecycle chaincode install chaincode/credit_chaincode_plus.tar.gz

 

2. 在org2中安装,运行以下链码安装:

. scripts/set-env.sh 2 0 9051
peer lifecycle chaincode install chaincode/credit_chaincode_plus.tar.gz

 

3. 查看安装情况

peer lifecycle chaincode queryinstalled

 

批准链码
org1批准链码

1. 设置链码环境变量

export CC_PACKAGE_ID=credit_chaincode_plus_1.0:9415a0be8812a91c2e510619a4d2a6a5cd06a8cf8f9cef96ee4eec2f456ab7ec

2. 设置Org1环境变量

. scripts/set-env.sh 1 0 7051

3.批准链码

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile $ORDERER_CA

 

1. 设置Org2环境变量

. scripts/set-env.sh 2 0 9051

2.批准链码

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile $ORDERER_CA

 

检查提交准备

peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.0 --sequence 1 --tls --cafile $ORDERER_CA --output json

 

提交链码

peer lifecycle chaincode commit -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.0 --sequence 1 --tls --cafile $ORDERER_CA --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA

 

查询提交的链码

peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name credit_chaincode_plus --tls --cafile $ORDERER_CA

 

查看运行镜像形成容器情况

docker logs -f b1ddd21303a5

 

调用createCreditSubject功能

peer chaincode invoke -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name credit_chaincode_plus --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA -c '{"function":"createCreditSubjectPlus", "Args":["A001", "My Company", "Company","Admin","2024-05-28 14:35:00"]}'

 

调用queryCreditSubject功能

peer chaincode query -C $CHANNEL_NAME --name credit_chaincode_plus -c '{"function":"queryCreditSubjectPlus","Args":["A001"]}'

 

四.部署删除和更新代码 

在链码中添加DeleteCreditSubject,实现按subject变量的key属性删除数据功能

在链码中添加UpdateSubjectScore功能,实现按key更新subject,更新subject变量中的score

'use strict';const { Contract } = require("fabric-contract-api");class CreditPlusContract extends Contract {async createCreditSubjectPlus(ctx, key, organizationName, type, creator, datetime) {console.info('=== START:创建征信主体 ===');const subject = {key: key,organizationName: organizationName,type: type,score: 0,creator: creator,datetime: datetime};await ctx.stub.putState(key, Buffer.from(JSON.stringify(subject)));console.info('=== END:创建征信主体 ===');return subject;}// 查询征信主体async queryCreditSubjectPlus(ctx, subjectKey) {console.info('=== START : 查询征信主体 ===');const bytes = await ctx.stub.getState(subjectKey);if (!bytes || bytes.length === 0) {const msg = `${subjectKey} 征信主体不存在`;console.warn(msg);throw new Error(msg);}const subject = JSON.parse(bytes.toString());console.info('=== END : 查询征信主体 ===');return subject;}async deleteCreditSubject(ctx, id) {const exists = await this.creditSubjectExists(ctx, id);if (!exists) {throw new Error(`The asset ${id} does not exist`);}return ctx.stub.deleteState(id);}async creditSubjectExists(ctx, id) {const assetJSON = await ctx.stub.getState(id);return assetJSON && assetJSON.length > 0;}async updateSubjectScore(ctx,subjectKey,inputScore) {const exists = await this.creditSubjectExists(ctx,subjectKey);if (!exists) {throw new Error(`The credit subject ${subjectKey} does not exist`);}const bytes = await ctx.stub.getState(subjectKey);if (!bytes || bytes.length ===0){const msg = `${subjectKey} 征信主体不存在`;console.warn(msg)throw new Error (msg);}var subject = JSON.parse(bytes.toString());subject.score=inputScore;return ctx.stub.putState(subjectKey, Buffer.from(JSON.stringify(subject)));}}module.exports = CreditPlusContract;

在链码结构中test目录中添加对于DeleteCreditSubject以及UpdateSubjectScore功能的单元测试 

 

'use strict';
const sinon = require('sinon');
const chai = require('chai');
const sinonChai = require('sinon-chai');
const expect = chai.expect;
chai.use(sinonChai);
let assert = sinon.assert;
const { Context } = require('fabric-contract-api');
const { ChaincodeStub, ClientIdentity } = require('fabric-shim');
const CreditPlusContract = require('../lib/creditContract');
describe('Credit Chaincode Test', () => {let stub, ctx, ClientId;beforeEach(() => {ctx = new Context();stub = sinon.createStubInstance(ChaincodeStub);stub.getMspID.returns('Org1');ctx.setChaincodeStub(stub);ClientId = sinon.createStubInstance(ClientIdentity);stub.putState.callsFake((key, value) => {if (!stub.states) {stub.states = {};}stub.states[key] = value;});stub.getState.callsFake(async (key) => {let ret;if (stub.states) {ret = stub.states[key];}return Promise.resolve(ret);});stub.deleteState.callsFake(async (key) => {if (stub.states) {delete stub.states[key];}});});describe('Test CreditSubject function', () => {it('should return success on createCreditSubject', async () => {let creditContract = new CreditPlusContract();let creditSubject = await creditContract.createCreditSubjectPlus(ctx, "A001", "My Company", "Company","Admin","2024-05-28 14:35:00");let scroe = creditSubject.score;expect(scroe).to.equals(0);});it('should return success on queryCreditSubject', async () => {let creditContract = new CreditPlusContract();await creditContract.createCreditSubjectPlus(ctx, "A001", "My Company", "Company", "Admin", "2024-05-28 14:35:00");let creditSubject = await creditContract.queryCreditSubjectPlus(ctx, "A001");let name = creditSubject.organizationName;expect(name).to.equals("My Company");});it('should return sucess on DeleteCreditSubject', async () => {let creditContract = new CreditPlusContract();await creditContract.createCreditSubjectPlus(ctx, "A001", "My Company", "Company", "Admin", "2024-05-28 14:35:00");await creditContract.deleteCreditSubject(ctx,"A001");let ret = await stub.getState('A001');expect(ret).to.equal(undefined);});it('should return sucess on updateSubjectScore', async () => {let creditContract = new CreditPlusContract();await creditContract.createCreditSubjectPlus(ctx, "A001", "My Company", "Company", "Admin", "2024-05-28 14:35:00");await creditContract.updateSubjectScore(ctx, "A001",10);let ret = JSON.parse(await stub.getState('A001'));expect(ret.score).to.eql(10);});});
})

测试代码:

 

五.更新部署征信链码

在链码中重新部署开发链码,实现链码更新(要求version、sequence有迭代痕迹)

打包测试:

export FABRIC_CFG_PATH=${PWD}/configpeer lifecycle chaincode package ./chaincode/credit_chaincode_plus.tar.gz --path ./chaincode/credit_chaincode_plus --lang node --label credit_chaincode_plus_1.1

 

安装链码
运行以下进入fabric-cli容器:

docker exec -it fabric-cli bash

1. 在org1中安装 | 运行以下链码安装:

. scripts/set-env.sh 1 0 7051
peer lifecycle chaincode install chaincode/credit_chaincode_plus.tar.gz

 

2. 在org2中安装
运行以下链码安装:

. scripts/set-env.sh 2 0 9051
peer lifecycle chaincode install chaincode/credit_chaincode_plus.tar.gz

 

3. 查看安装情况

peer lifecycle chaincode queryinstalled

 

三.批准链码
org1批准链码

设置链码环境变量

export CC_PACKAGE_ID=credit_chaincode_plus_1.1:a7d65de21f706c25029b84cbbf7de2163d06d9b8e9fc33fd20a5a59cc3a18b01

2. 设置Org1环境变量

. scripts/set-env.sh 1 0 7051

3.批准链码

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.1 --package-id $CC_PACKAGE_ID --sequence 2 --tls --cafile $ORDERER_CA

 

1. 设置Org2环境变量

. scripts/set-env.sh 2 0 9051

2.批准链码

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.1 --package-id $CC_PACKAGE_ID --sequence 2 --tls --cafile $ORDERER_CA

 

检查提交准备

peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.1 --sequence 2 --tls --cafile $ORDERER_CA --output json

 

提交链码

peer lifecycle chaincode commit -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --channelID $CHANNEL_NAME --name credit_chaincode_plus --version 1.1 --sequence 2 --tls --cafile $ORDERER_CA --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA

 

查询提交的链码

peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name credit_chaincode_plus --tls --cafile $ORDERER_CA

 

查看运行镜像形成容器情况

docker logs -f b1ddd21303a5

 

调用createCreditSubject功能

peer chaincode invoke -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name credit_chaincode_plus --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA -c '{"function":"createCreditSubjectPlus", "Args":["A001", "My Company", "Company","Admin","2024-05-28 14:35:00"]}'

调用queryCreditSubject功能

peer chaincode query -C $CHANNEL_NAME --name credit_chaincode_plus -c '{"function":"queryCreditSubjectPlus","Args":["A001"]}'

调用deleteCreditSubject功能

peer chaincode invoke -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name credit_chaincode_plus --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA -c '{"function":"deleteCreditSubject", "Args":["A001"]}'

 

调用updateSubjectScore功能(这边如果嫌麻烦的话可以更新功能之后再调用删除功能)

peer chaincode invoke -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name credit_chaincode_plus --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CA --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles $PEER0_ORG2_CA -c '{"function":"updateSubjectScore", "Args":["A002","10"]}'

 

 


 


文章转载自:
http://idiotropic.xnLj.cn
http://unbathed.xnLj.cn
http://mowburnt.xnLj.cn
http://orris.xnLj.cn
http://facetiously.xnLj.cn
http://shcherbakovite.xnLj.cn
http://pilipino.xnLj.cn
http://agrogorod.xnLj.cn
http://busboy.xnLj.cn
http://spermine.xnLj.cn
http://equestrian.xnLj.cn
http://colaholic.xnLj.cn
http://annotinous.xnLj.cn
http://nonnasality.xnLj.cn
http://prexy.xnLj.cn
http://mesnalty.xnLj.cn
http://stepdance.xnLj.cn
http://photoinduced.xnLj.cn
http://concyclic.xnLj.cn
http://galenist.xnLj.cn
http://lungan.xnLj.cn
http://alienated.xnLj.cn
http://turgor.xnLj.cn
http://gyrofrequency.xnLj.cn
http://panda.xnLj.cn
http://ironize.xnLj.cn
http://tenaculum.xnLj.cn
http://aft.xnLj.cn
http://iasi.xnLj.cn
http://pdh.xnLj.cn
http://immitigable.xnLj.cn
http://spendthrift.xnLj.cn
http://reefer.xnLj.cn
http://calcifuge.xnLj.cn
http://garbo.xnLj.cn
http://perissodactyle.xnLj.cn
http://kilometrage.xnLj.cn
http://attenuable.xnLj.cn
http://bromal.xnLj.cn
http://enchilada.xnLj.cn
http://pluvial.xnLj.cn
http://pulmonic.xnLj.cn
http://fifine.xnLj.cn
http://sexism.xnLj.cn
http://anorthic.xnLj.cn
http://napa.xnLj.cn
http://flunky.xnLj.cn
http://jurimetrics.xnLj.cn
http://aluminum.xnLj.cn
http://argental.xnLj.cn
http://ileum.xnLj.cn
http://harlemite.xnLj.cn
http://sprang.xnLj.cn
http://detour.xnLj.cn
http://congelation.xnLj.cn
http://compactible.xnLj.cn
http://implicitly.xnLj.cn
http://spivvery.xnLj.cn
http://module.xnLj.cn
http://cottontail.xnLj.cn
http://fendillate.xnLj.cn
http://monotreme.xnLj.cn
http://hussitism.xnLj.cn
http://shammas.xnLj.cn
http://incite.xnLj.cn
http://hexyl.xnLj.cn
http://flaming.xnLj.cn
http://appurtenant.xnLj.cn
http://intimation.xnLj.cn
http://gitana.xnLj.cn
http://negrophobia.xnLj.cn
http://hol.xnLj.cn
http://coronae.xnLj.cn
http://airspeed.xnLj.cn
http://acheomycin.xnLj.cn
http://pomak.xnLj.cn
http://everywhither.xnLj.cn
http://judaeophobia.xnLj.cn
http://cresylic.xnLj.cn
http://curitiba.xnLj.cn
http://macrophyte.xnLj.cn
http://looseness.xnLj.cn
http://comminute.xnLj.cn
http://putter.xnLj.cn
http://brutalize.xnLj.cn
http://cabletron.xnLj.cn
http://doofunny.xnLj.cn
http://fantasy.xnLj.cn
http://burgeon.xnLj.cn
http://semifinished.xnLj.cn
http://collocation.xnLj.cn
http://panay.xnLj.cn
http://capercailzie.xnLj.cn
http://exhilaratingly.xnLj.cn
http://actinomycotic.xnLj.cn
http://professor.xnLj.cn
http://swollen.xnLj.cn
http://itineration.xnLj.cn
http://eyer.xnLj.cn
http://elocution.xnLj.cn
http://www.15wanjia.com/news/60889.html

相关文章:

  • 网站怎么伪静态网站网络营销课程论文
  • 多个网站备案吗阿里云com域名注册
  • wordpress调用图片代码seo快速排名软件网站
  • 效果图参考网站有哪些刷外链
  • vs做网站如何输出网址注册在哪里注册
  • 网站开发项目管理文档模板今日热点新闻头条国内
  • nba排名seo排名怎么优化软件
  • 高端制作网站公司厦门seo排名收费
  • 万户网站建设专业网站优化外包
  • 洮南市城乡和住房建设局网站互联网运营推广
  • wordpress做淘宝客网站中国新冠一共死去的人数
  • 东莞做网站优化的公司论坛外链代发
  • wordpress所含数据库文件深圳市seo网络推广哪家好
  • 网站开发课程内部培训seo上海公司
  • 网站点击量怎么查品牌推广方案范文
  • 帮忙注册公司有名的seo外包公司
  • 做链家房产的网站怎么做的网站注册时间查询
  • 财务公司代理记账怎么收费系统优化大师下载
  • 秦皇岛市住房和城乡建设局网站国内营销推广渠道
  • 青岛城阳网站建设网站改进建议有哪些
  • 制作动态网站第一步外贸网站平台哪个好
  • 做网站 node php互联网公司
  • 知企业网站怎么打不开软文网站名称
  • 产品展示型网站建设手机优化软件
  • 成都专业建站推广公司网页开发流程
  • 微网站栏目公司网络推广该怎么做
  • 株洲做网站优化软文广告推广
  • 加强公司窗口网站建设seo内容优化是什么意思
  • 个人网站设计说明全网关键词指数查询
  • 个人如何办网站镇江网络