griffo-io / tron.net

GNU Lesser General Public License v3.0
40 stars 11 forks source link

Wallet implementation creates new GRPC client and channel for each call #7

Closed maincoon closed 4 years ago

maincoon commented 4 years ago

GRPC recommends reuse channels and it's calls also thread safe. Current implementation of IWallet at https://github.com/griffo-io/tron.net/blob/master/src/Tron.Net.Client/Wallet.cs violates this recomandations and creates new client for each call. Backend with this code starts to absorb resources (CPU and memory) while using wallet for some long time. Finally I've created own IWallet available in attach.

Thank you. TRONClient.cs.txt

dariogriffo commented 4 years ago

I will see if I can do some work this weekend updating the library. Sorry, been away for a while

wasimjee commented 4 years ago

@maincoon

Do u have the codes updated in github?

i am unable to connect and access the Wallet. Any Help.

dariogriffo commented 4 years ago

Code is updated now, there is only 1 instance of the channel created. Ideally you want the GRPC Channel factory to be a singleton created by your IoC framework