Skip to content
This repository was archived by the owner on Mar 9, 2024. It is now read-only.
This repository was archived by the owner on Mar 9, 2024. It is now read-only.

Digest HTTP Auth for wallet JSON RPC should be reused #104

Closed
@ghost

Description

Once a wallet object is instantiated, all calls to it invoke a new HTTPDigestAuth object.

I think this should be cached, or some kind of requests session used.

Let's say you have pseudocode like this:

wallet = JSONRPCWallet(user="user", pass="pass")
wallet.height()  # This attempts with no auth, gets 401ed and a nonce returned, then attempts again with auth.
wallet.height()  # This doesn't cache the old nonce, because the HTTPDigestAuth object is lost, so it does it all over again.

I think we can make the HTTPDigestAuth object once here: https://github.com/monero-ecosystem/monero-python/blob/master/monero/backends/jsonrpc/daemon.py#L26

This way there's only one time getting the digest, and follow up commands are much faster.

Maybe:

self._auth = requests.auth.HTTPDigestAuth(user, password) in __init__()?

We might not even have to set self.user and self.password with this.

Let me know if this doesn't make sense or anything like that.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions