Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (!mspId) {
throw new Error('"options.mspId" is required to generate unsigned fabric service registration');
}
}
if (!identity) {
identity = new Identity(certificate, null, mspId);
txId = new TransactionID(identity, options.admin === true);
}
// The behavior when a missing block is encountered
let behavior = fabprotos.orderer.SeekInfo.SeekBehavior.BLOCK_UNTIL_READY;
// build start
const seekStart = new fabprotos.orderer.SeekPosition();
if (!this._starting_block_number || this._starting_block_number === NEWEST) {
const seekNewest = new fabprotos.orderer.SeekNewest();
seekStart.setNewest(seekNewest);
} else if (this._starting_block_number === OLDEST) {
const seekOldest = new fabprotos.orderer.SeekOldest();
seekStart.setOldest(seekOldest);
} else if (this._starting_block_number) {
const seekSpecifiedStart = new fabprotos.orderer.SeekSpecified();
seekSpecifiedStart.setNumber(this._starting_block_number);
seekStart.setSpecified(seekSpecifiedStart);
}
// build stop
const seekStop = new fabprotos.orderer.SeekPosition();
if (this._ending_block_number === NEWEST) {
this._ending_block_newest = true;
function decodeConfigValueConsensusType(proto_config_value, config_value) {
const proto_consensus_type = fabprotos.orderer.ConsensusType.decode(proto_config_value.value.value);
config_value.value.type = proto_consensus_type.getType(); // string
return config_value;
}
throw new Error('"options.mspId" is required to generate unsigned fabric service registration');
}
}
if (!identity) {
identity = new Identity(certificate, null, mspId);
txId = new TransactionID(identity, options.admin === true);
}
// The behavior when a missing block is encountered
let behavior = fabprotos.orderer.SeekInfo.SeekBehavior.BLOCK_UNTIL_READY;
// build start
const seekStart = new fabprotos.orderer.SeekPosition();
if (!this._starting_block_number || this._starting_block_number === NEWEST) {
const seekNewest = new fabprotos.orderer.SeekNewest();
seekStart.setNewest(seekNewest);
} else if (this._starting_block_number === OLDEST) {
const seekOldest = new fabprotos.orderer.SeekOldest();
seekStart.setOldest(seekOldest);
} else if (this._starting_block_number) {
const seekSpecifiedStart = new fabprotos.orderer.SeekSpecified();
seekSpecifiedStart.setNumber(this._starting_block_number);
seekStart.setSpecified(seekSpecifiedStart);
}
// build stop
const seekStop = new fabprotos.orderer.SeekPosition();
if (this._ending_block_number === NEWEST) {
this._ending_block_newest = true;
const seekNewest = new fabprotos.orderer.SeekNewest();
seekStop.setNewest(seekNewest);
function decodeConfigValueBatchTimeout(proto_config_value, config_value) {
const proto_batch_timeout = fabprotos.orderer.BatchTimeout.decode(proto_config_value.value.value);
config_value.value.timeout = proto_batch_timeout.getTimeout(); // string
return config_value;
}
seekStart.setOldest(seekOldest);
} else if (this._starting_block_number) {
const seekSpecifiedStart = new fabprotos.orderer.SeekSpecified();
seekSpecifiedStart.setNumber(this._starting_block_number);
seekStart.setSpecified(seekSpecifiedStart);
}
// build stop
const seekStop = new fabprotos.orderer.SeekPosition();
if (this._ending_block_number === NEWEST) {
this._ending_block_newest = true;
const seekNewest = new fabprotos.orderer.SeekNewest();
seekStop.setNewest(seekNewest);
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else if (this._ending_block_number === OLDEST) {
const seekOldest = new fabprotos.orderer.SeekOldest();
seekStop.setOldest(seekOldest);
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else {
const seekSpecifiedStop = new fabprotos.orderer.SeekSpecified();
if (this._ending_block_number) {
seekSpecifiedStop.setNumber(this._ending_block_number);
// user should be told that the block does not exist
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else {
seekSpecifiedStop.setNumber(Long.MAX_VALUE);
}
seekStop.setSpecified(seekSpecifiedStop);
}
// seek info with all parts
const seekInfo = new fabprotos.orderer.SeekInfo();
seekStart.setSpecified(seekSpecifiedStart);
}
// build stop
const seekStop = new fabprotos.orderer.SeekPosition();
if (this._ending_block_number === NEWEST) {
this._ending_block_newest = true;
const seekNewest = new fabprotos.orderer.SeekNewest();
seekStop.setNewest(seekNewest);
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else if (this._ending_block_number === OLDEST) {
const seekOldest = new fabprotos.orderer.SeekOldest();
seekStop.setOldest(seekOldest);
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else {
const seekSpecifiedStop = new fabprotos.orderer.SeekSpecified();
if (this._ending_block_number) {
seekSpecifiedStop.setNumber(this._ending_block_number);
// user should be told that the block does not exist
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else {
seekSpecifiedStop.setNumber(Long.MAX_VALUE);
}
seekStop.setSpecified(seekSpecifiedStop);
}
// seek info with all parts
const seekInfo = new fabprotos.orderer.SeekInfo();
seekInfo.setStart(seekStart);
seekInfo.setStop(seekStop);
// BLOCK_UNTIL_READY will mean hold the stream open and keep sending as
// the blocks come in
function decodeConfigValueChannelRestrictions(proto_config_value, config_value) {
const proto_channel_restrictions = fabprotos.orderer.ChannelRestrictions.decode(proto_config_value.value.value);
config_value.value.max_count = proto_channel_restrictions.getMaxCount().toString(); // unit64
return config_value;
}
} else if (this._starting_block_number === OLDEST) {
const seekOldest = new fabprotos.orderer.SeekOldest();
seekStart.setOldest(seekOldest);
} else if (this._starting_block_number) {
const seekSpecifiedStart = new fabprotos.orderer.SeekSpecified();
seekSpecifiedStart.setNumber(this._starting_block_number);
seekStart.setSpecified(seekSpecifiedStart);
}
// build stop
const seekStop = new fabprotos.orderer.SeekPosition();
if (this._ending_block_number === NEWEST) {
this._ending_block_newest = true;
const seekNewest = new fabprotos.orderer.SeekNewest();
seekStop.setNewest(seekNewest);
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else if (this._ending_block_number === OLDEST) {
const seekOldest = new fabprotos.orderer.SeekOldest();
seekStop.setOldest(seekOldest);
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else {
const seekSpecifiedStop = new fabprotos.orderer.SeekSpecified();
if (this._ending_block_number) {
seekSpecifiedStop.setNumber(this._ending_block_number);
// user should be told that the block does not exist
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
} else {
seekSpecifiedStop.setNumber(Long.MAX_VALUE);
}
seekStop.setSpecified(seekSpecifiedStop);
}
constructor(name = checkParameter('name'), client = checkParameter('client'), mspid) {
logger.debug(`${TYPE}.constructor[${name}] - start `);
super(name, client);
this.mspid = mspid;
this.type = TYPE;
this.serviceClass = fabprotos.orderer.AtomicBroadcast;
}
constructor(url, opts) {
super(url, opts);
logger.debug('Orderer.const - url: %s timeout: %s', url, this._request_timeout);
this._ordererClient = new fabprotos.orderer.AtomicBroadcast(this._endpoint.addr, this._endpoint.creds, this._options);
this._sendDeliverConnect = false;
}