Comments (3)
Channel.js
/**
* Send signed transaction proposal to peer
*
* @param {SignedProposal} request signed endorse transaction proposal, this signed
* proposal would be send to peer directly.
* @param {number} timeout the timeout setting passed on sendSignedProposal
*/
async sendSignedProposal(request, timeout) {
return Channel.sendSignedProposal(request, timeout);
}
/**
* Send signed transaction proposal to peer
*
* @param {SignedProposal} request signed endorse transaction proposal, this signed
* proposal would be send to peer directly.
* @param {number} timeout the timeout setting passed on sendSignedProposal
*/
static async sendSignedProposal(request, timeout) {
const responses = await client_utils.sendPeersProposal(request.targets, request.signedProposal, timeout);
return responses;
}
client-utils.js
/*
* This function will return one Promise when sending a proposal to many peers
*/
module.exports.sendPeersProposal = async (peers, proposal, timeout) => {
let targets = peers;
if (!Array.isArray(peers)) {
targets = [peers];
}
// create array of promises mapping peers array to peer parameter
// settle all the promises and return array of responses
const promises = targets.map(async (peer) => {
return peer.sendProposal(proposal, timeout);
});
const responses = [];
const results = await settle(promises);
results.forEach((result) => {
if (result.isFulfilled()) {
logger.debug(`sendPeersProposal - Promise is fulfilled: ${result.value()}`);
responses.push(result.value());
} else {
logger.debug(`sendPeersProposal - Promise is rejected: ${result.reason()}`);
responses.push(result.reason());
}
});
return responses;
};
from estate-sample.
sendPeersProposal は、どうも fabcar の queryByChaincode でも使われているため
offlineの時と、onlineの時で何がちがっているか調べる。
responseが変わる意味がわかるかもしれない
log挿入場所
module.exports.sendPeersProposal = async (peers, proposal, timeout) => {
let targets = peers;
if (!Array.isArray(peers)) {
targets = [peers];
}
// create array of promises mapping peers array to peer parameter
// settle all the promises and return array of responses
const promises = targets.map(async (peer) => {
return peer.sendProposal(proposal, timeout);
});
const responses = [];
const results = await settle(promises);
results.forEach((result) => {
if (result.isFulfilled()) {
logger.debug(`sendPeersProposal - Promise is fulfilled: ${result.value()}`);
responses.push(result.value());
} else {
logger.debug(`sendPeersProposal - Promise is rejected: ${result.reason()}`);
responses.push(result.reason());
}
});
console.log('====sendPeersProposal==== responses', responses);
console.log('====sendPeersProposal==== responses.response', responses[0].response.payload.toString());
return responses;
};
fabcar online
[ { version: 1,
timestamp: null,
response:
{ status: 200,
message: '',
payload: <Buffer 22 5b 7b 5c 22 4b 65 79 5c 22 3a 5c 22 43 41 52 30 5c 22 2c 5c 22 52 65 63 6f 72 64 5c 22 3a 7b 5c 22 63 6f 6c 6f 72 5c 22 3a 5c 22 62 6c 75 65 5c 22 ... > },
payload: <Buffer 0a 20 da 35 77 f8 75 b6 7b 7a fb 50 b2 e0 62 c9 91 c1 d7 ef eb ef da 09 40 8e 66 83 74 fa 04 af 61 53 12 8c 0d 0a c1 01 12 a6 01 0a 06 66 61 62 63 61 ... >,
endorsement:
{ endorser: <Buffer 0a 07 4f 72 67 31 4d 53 50 12 aa 06 2d 2d 2d 2d 2d 42 45 47 49 4e 20 43 45 52 54 49 46 49 43 41 54 45 2d 2d 2d 2d 2d 0a 4d 49 49 43 4b 44 43 43 41 63 ... >,
signature: <Buffer 30 45 02 21 00 83 42 02 fe b0 27 45 a9 0b 1d b3 4a ed 75 d2 fc d2 12 49 e6 a3 23 ae 9d e5 66 1c 6e 60 2c 86 27 02 20 75 ba 17 b5 b4 ff 45 4f 6e 12 2c ... > },
peer:
{ url: 'grpcs://localhost:7051',
name: 'localhost:7051',
options: [Object] } } ]
Query has completed, checking results
fabcar offline
[ { version: 1,
timestamp: null,
response:
{ status: 200,
message: '',
payload: <Buffer 22 5b 7b 5c 22 4b 65 79 5c 22 3a 5c 22 43 41 52 30 5c 22 2c 5c 22 52 65 63 6f 72 64 5c 22 3a 7b 5c 22 63 6f 6c 6f 72 5c 22 3a 5c 22 62 6c 75 65 5c 22 ... > },
payload: <Buffer 0a 20 55 37 f5 fa c7 ce 0f 83 bf 82 45 a6 c4 22 c9 b9 e7 65 a6 c2 41 0a 04 60 72 ed e5 14 ca 4c 0b b2 12 8c 0d 0a c1 01 12 a6 01 0a 06 66 61 62 63 61 ... >,
endorsement:
{ endorser: <Buffer 0a 07 4f 72 67 31 4d 53 50 12 aa 06 2d 2d 2d 2d 2d 42 45 47 49 4e 20 43 45 52 54 49 46 49 43 41 54 45 2d 2d 2d 2d 2d 0a 4d 49 49 43 4b 44 43 43 41 63 ... >,
signature: <Buffer 30 44 02 20 79 cd 4e 5d 79 cc 64 9a 5e 7b d6 96 a9 6f 01 21 0c 8d e3 54 16 1b a1 f0 38 61 d2 aa 7c 94 fb 0f 02 20 58 e1 63 66 8d 20 b8 86 d1 08 5b 5d ... > },
peer:
{ url: 'grpcs://localhost:7051',
name: 'localhost:7051',
options: [Object] } } ]
とおもったら、いっしょのが返ってきたっぽい?
sendPeersProposal の段階ではデータ返ってきているが、
sendSignedTransaction の responseはちゃんと返ってきていないのは、、、なぜz?
以下場所で
==== sendSignedProposal === Promise { }
になってしまう。これが原因。
async sendSignedProposal(request, timeout) {
const responses = Channel.sendSignedProposal(request, timeout);
console.log('==== sendSignedProposal ===', responses);
// console.log('1====sendSignedProposal==== responses.response', responses[0].response.payload.toString());
return responses;
}
from estate-sample.
と、色々書いたが以下のメソッドのresponseで拾えていた
const proposalResponses = await channel.sendSignedProposal(sendSignedProposalReq)
from estate-sample.
Related Issues (15)
- 要件定義
- ReactNativeでfabricのlib使えるかサンプルアプリ作成 HOT 7
- Node.js が使えるクライアントアプリを見つけてfabric libを使う HOT 13
- queryByChaincode が offlineでも使えるか調べる HOT 6
- fabric-ca-client の中身を探る
- Electronで画面を作る HOT 1
- データモデル定義 HOT 3
- nodeのフレームワーク選定 HOT 3
- 開発方針の決定 HOT 6
- fabricのロールバック処理対応
- chainnodeを動かす HOT 3
- 起動用script作成
- Estate売買実装 HOT 6
- Client側で秘密鍵&公開鍵を作成してtransaction実行させてみる HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from estate-sample.