is it possible to prioritize orderer when submitting transactions through fabric-sdk-node?

72 Views Asked by At

I'm writing a fabric client application using nodejs and the latest fabric-network library. I have setup multiple orderer nodes running in VMs and want to prioritize which orderer node to be used when submitting transactions.

I wrote my own connection profile including the above orderer nodes and let the application use it to create gateway object. Then, I'm calling transaction#submit method to execute transactions. I want to use the nearest orderer node from the application but I don't know if it's possible.

I read through fabric-skd-node source code and found that commitment procedure is done at Commit.js#send method and it pick the first healthy orderer node from the orderer list retrieved using Channel.js#getTargetCommitters method. So, my rough guess is that the first orderer node listed in connection profile is used if it's connectable.

Please correct me if I'm wrong, I'd be very grateful.

1

There are 1 best solutions below

0
On BEST ANSWER

It looks like you are correct in the case that you are not using service discovery, and you client is only using nodes defined in your connection profile.

If you are using service discovery to dynamically discover network nodes then the list of orderers is randomised on each invocation to help distribute load more evenly across orderers and better handle orderer outages.

https://github.com/hyperledger/fabric-sdk-node/blob/3da1d0beeb5274b021d6bd4a6d8ea69d5642d409/fabric-common/lib/DiscoveryHandler.js#L106-L109

Remember that orderers will replicate transactions they receive to other orderers to maintain consistency and avoid single points of failure, so you are not avoiding transactions being sent to more distant ordering nodes.