2017-10-27 6 views
0

내가 Hyperledger 런타임에 연결하려면 다음 코드를 가진 NodeJS 서버를 실행하고 Hyperledger 작곡가 거래에서 이벤트를 참조하는 방법 :에 가입

내가 연결 한 후 반환 된 데이터를 볼
const BusinessNetworkConnection = require("composer-client") 
    .BusinessNetworkConnection; 
this.businessNetworkConnection = new BusinessNetworkConnection(); 
this.CONNECTION_PROFILE_NAME = "hlfv1"; 
this.businessNetworkIdentifier = "testNetwork"; 
this.businessNetworkConnection 
    .connect(
    this.CONNECTION_PROFILE_NAME, 
    this.businessNetworkIdentifier, 
    "admin", 
    "adminpwd" 
) 
    .then(result => { 
    this.businessNetworkDefinition = result; 
    console.log("BusinessNetworkConnection: ", result); 
    }) 
    .then(() => { 
    // Subscribe to events. 
    this.businessNetworkConnection.on("events", events => { 
     console.log("**********business event received**********", events); 
    }); 
    }) 
    // and catch any exceptions that are triggered 
    .catch(function(error) { 
    throw error; 
    }); 

은 이루어진 것으로, result 개체이며 배포 된 올바른 네트워크 데이터입니다.

그러나 트랜잭션을 제출하고 생성 된 REST API를 통해 요청을하면 내 서버에서 이벤트를 볼 수 없습니다. 역사가에서는 사건이 발생한다는 것을 알 수 있습니다. 내 거래에서 발생하는 사건을보기 위해해야 ​​할 일이 있습니까?

답변

1

같은 종류의 테스트를 시도했지만 이벤트를받을 수있었습니다. 내 테스트 코드와 당신을 비교, 나는 다음과 같은 차이가 발견.

this.bizNetworkConnection.on ('이벤트'

this.bizNetworkConnection.on ('이벤트'나는 그것이 도움이되기를 바랍니다

+0

대단한 작품! 어리석은 실수 ... – TheOkayCoder