Я пытаюсь написать скрипт для регистрации и регистрации нового пользователя в Hyperledger Fabri c.
Я взял базу от этого Github командой Конвекторов.
Я отредактировал свой сценарий с помощью переменной c dinami для enrollmentID
(просто "пользователь", соединенный с отметкой времени unix вместо строки stati c "chaincodeAdmin"), но он дает мне это ошибка:
$ node register.js 'dottore' 'trauma'
Store path:/home/convector/hyperledger-fabric-network/.hfc-org1
Successfully loaded admin from persistence
Successfully registered chaincodeAdmin - secret:EEwQBeUqLfEW
Failed to register: ReferenceError: utente is not defined
Это фрагмент кода, который, я думаю, не работает.
// [..]
// at this point we should have the admin user
// first need to register the user with the CA server
var ruolo = process.argv[2];
var patologia = process.argv[3];
var date = new Date();
var timestamp = date.getTime();
var nuovoEnroll = "User" + timestamp;
console.log(timestamp, nuovoEnroll);
return fabric_ca_client.register({ enrollmentID: nuovoEnroll, attrs: [{ ruolo: ruolo, ecert:true, patologia: patologia, ecert: true }]}, admin_user);
}).then((secret) => {
// next we need to enroll the user with CA server
console.log('Successfully registered new user - secret:' + secret);
return fabric_ca_client.enroll({ enrollmentID: nuovoEnroll, enrollmentSecret: secret });
}).then((enrollment) => {
console.log('Successfully enrolled member user');
return fabric_client.createUser({
username: nuovoEnroll,
mspid: 'org1MSP',
cryptoContent: { privateKeyPEM: enrollment.key.toBytes(), signedCertPEM: enrollment.certificate }
});
}).then((user) => {
member_user = user;
return fabric_client.setUserContext(member_user);
}).then(() => {
console.log('user was successfully registered and enrolled and is ready to interact with the fabric network');
}).catch((err) => {
console.error('Failed to register: ' + err);
if (err.toString().indexOf('Authorization') > -1) {
console.error('Authorization failures may be caused by having admin credentials from a previous CA instance.\n' +
'Try again after deleting the contents of the store directory ' + hurleyIdentityPath);
}
});