Ubuntu 20.04
Hyperledger Fabric 2.3.3
SDK对应的Go 1.17.5
链码对应的Go 1.18
Fabric-sdk-go 1.0.0
Docker 20.10.12
Docker-Compose 2.11.2
peer chaincode invoke -o localhost:7050 – ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID cychannel --name marriage --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ‘{“function”:“Register”,“Args”:[“1001”,“jack”]}’
Error: The required parameter ‘channelID’ is empty. Rerun the command with -C flag
所调用命令的缩进有问题(命令从本地拷贝到虚拟机易出错), --后不能有空格
2023-01-03 21:54:08.247 CST 0001 INFO [chaincodeCmd] chaincodeInvokeOrQuery -> Chaincode invoke successful. result: status:200
peer chaincode query -C cychannel -n marriage -c ‘{“Args”:[“searchMarriageInfoByClientId”,“1001”]}’
Error: endorsement failure during query. response: status:500 message:“make sure the chaincode marriage has been successfully defined on channel cychannel and try again: chaincode definition for ‘marriage’ exists, but chaincode is not installed”
在确保链码提交成功的情况下出现该错误,原因是函数名小写开头,只在本包内调用有效,外部无法调用。将函数名改为大写开头即可。
{“id”:“1001”,“marriage_id”:“”,“person_name”:“jack”,“is_married”:false}
本地主机通过Go-SDK调用远程云服务器的链码(防火墙已开放 TCP 7051 和 9051 端口)。
我在链码函数中添加了权限判断(只有拥有org1证书的客户端才能访问):

结果,我在sdk中初始化合约对象时,用的是org2的证书。于是,删除生成的wallet文件(这一步很关键),将代码中的org2全部修改成org1,成功。
event service creation failed: could not get chConfig cache reference: QueryBlockConfig failed: QueryBlockConfig failed: queryChaincode failed: Transaction processing for endorser [192.168.6.149:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [192.168.6.149:7051]: connection is in TRANSIENT_FAILURE
我本地的SDK项目结构如下:

我使用的配置文件是fabric-samples下test-network下的,需要提前准备三件事情:
① 修改本地的organizations中的connection-org1.yaml的url为远程主机的IP:


② 在本地hosts文件中添加远程主机的域名解析。

③ 每次链码部署成功后,都需要从test-network中更新本地项目的organizations(一个organizations只能用于一个SDK项目)。

确保上述工作无误后,运行main.go调用远程链码报错…
原因是fabric-sdk-go与fabric2.4.x版本不兼容,更换为fabric2.3.3后成功解决问题。
(如果想使用2.4.x的版本,需要借助新的sdk:fabric-gateway,其Github地址为https://github.com/hyperledger/fabric-gateway)

Go的版本问题,我本地的Go版本是1.19.2,更换为1.17.5后,问题解决。
SDK终于启动成功,并能正常调用远程链码。

需要修改fabric-samples/test-network/scripts下的createChannel.sh文件,将createChannel函数中的–channel -id修改为–channelID

还是Go版本的问题,我将Go 1.19.2更换为Go 1.17.5之后,问题解决。
wallet, err := gateway.NewFileSystemWallet(“org1/wallet”)
Error: endorsement failure during invoke. response: status:500 message:“error in simulation: failed to execute transaction 306ed1ca53720d68d6e392198014ca2e91fbfa79a9f6e6be7a7e40f497bf4b1e: could not launch chaincode rent_1.0:e678092929f2e636a5bcb1ddbfd52dd04c45b1fc5128a2a4cf883cb5c7991ee9: chaincode registration failed: container exited with 2”
链码本身的问题。链码函数都有一个指针类型的receiver,对应的实例是继承了contractapi.Contract的合约。而我不小心,将实例写成了某个自定义的结构体,导致出错。
定义的合约:

错误:

正确:


go mod tidy默认导入最新版本,截至目前(2023.03.17)contractapi的最新版本是1.2.1,要求go的版本是1.19以上(一个月前,contractapi最新版本是1.2.0,支持go 1.18,并不会出现这个问题),而我本地的go是1.18版本,因此安装链码会出现错误。
而我将go版本更换为1.19之后,安装链码时会有意外的错误…因此,我只能修改contractapi的版本使其支持低版本的go。由于我链码所在的虚拟机的go版本是1.18,因此我将contractapi的版本更改为1.2.0(1.2.0要求go版本是1.17以上),这样就兼容了。
module xxx
go 1.18
require github.com/hyperledger/fabric-contract-api-go v1.2.0
require (
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/gobuffalo/envy v1.10.1 // indirect
github.com/gobuffalo/packd v1.0.1 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hyperledger/fabric-chaincode-go v0.0.0-20220720122508-9207360bbddd // indirect
github.com/hyperledger/fabric-protos-go v0.0.0-20220613214546-bf864f01d75e // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220719170305-83ca9fad585f // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
“Failed to submit: Multiple errors occurred: - Transaction processing for endorser [localhost:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [localhost:7051]: connection is in TRANSIENT_FAILURE - Transaction processing for endorser [localhost:9051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [localhost:9051]: connection is in TRANSIENT_FAILURE”
SDK中设置DISCOVERY_AS_LOCALHOST为false,否则会向本地发送请求,链码放在服务器中,显然不可能访问到。

panic: Failed to submit: CreateAndSendTransaction failed: SendTransaction failed: calling orderer ‘orderer.example.com:7050’ failed: Orderer Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [orderer.example.com:7050]: waiting for connection failed: context deadline exceeded [recovered]
panic: Failed to submit: CreateAndSendTransaction failed: SendTransaction failed: calling orderer ‘orderer.example.com:7050’ failed: Orderer Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [orderer.example.com:7050]: waiting for connection failed: context deadline exceeded
看报错信息,好像是访问orderer节点失败,原来是服务器没有开放7050端口。
开放服务器端口

我在本地host文件中添加了多个服务器的域名解析,也就是同一个组织域名对应了多个ip。需要保证host文件中的ip是你要访问的链码所在服务器的ip。
PWD=‘/myFabric/fabric-samples/test-network’
export PATH=${PWD}/…/bin:$PATH
export FABRIC_CFG_PATH=${PWD}/…/config/
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID=“Org1MSP”
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051
设置以上环境变量后,命令行调用链码函数即可。
对于表示单个对象的json串,反序列化到map[string]interface{};
对于表示对象数组的json串,反序列化到[]map[string]interface{};
//根据用户ID获取该用户的缴税记录
taxes, err := utils.TaxContract.EvaluateTransaction("GetAllTaxesByUserId", userId)
if err != nil {
return err
}
var res []map[string]interface{}
json.Unmarshal(taxes, &res)
fmt.Println(res)

给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
我将应用程序升级到Rails4,一切正常。我可以登录并转到我的编辑页面。也更新了观点。使用标准View时,用户会更新。但是当我添加例如字段:name时,它不会在表单中更新。使用devise3.1.1和gem'protected_attributes'我需要在设备或数据库上运行某种更新命令吗?我也搜索过这个地方,找到了许多不同的解决方案,但没有一个会更新我的用户字段。我没有添加任何自定义字段。 最佳答案 如果您想允许额外的参数,您可以在ApplicationController中使用beforefilter,因为Rails4将参数
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我意识到这可能是一个非常基本的问题,但我现在已经花了几天时间回过头来解决这个问题,但出于某种原因,Google就是没有帮助我。(我认为部分问题在于我是一个初学者,我不知道该问什么......)我也看过O'Reilly的RubyCookbook和RailsAPI,但我仍然停留在这个问题上.我找到了一些关于多态关系的信息,但它似乎不是我需要的(尽管如果我错了请告诉我)。我正在尝试调整MichaelHartl'stutorial创建一个包含用户、文章和评论的博客应用程序(不使用脚手架)。我希望评论既属于用户又属于文章。我的主要问题是:我不知道如何将当前文章的ID放入评论Controller。
首先回顾一下拉格朗日定理的内容:函数f(x)是在闭区间[a,b]上连续、开区间(a,b)上可导的函数,那么至少存在一个,使得:通过这个表达式我们可以知道,f(x)是函数的主体,a和b可以看作是主体函数f(x)中所取的两个值。那么可以有, 也就意味着我们可以用来替换 这种替换可以用在求某些多项式差的极限中。方法: 外层函数f(x)是一致的,并且h(x)和g(x)是等价无穷小。此时,利用拉格朗日定理,将原式替换为 ,再进行求解,往往会省去复合函数求极限的很多麻烦。使用要注意:1.要先找到主体函数f(x),即外层函数必须相同。2.f(x)找到后,复合部分是等价无穷小。3.要满足作差的形式。如果是加