Skip to content

Add batch support. #20

@aliqandil

Description

@aliqandil

The title is pretty self explanatory, I'm not familiar enough with the project to create a pull request, but this is the patch I use to get this functionality:

import orjson
from bitcoinrpc import BitcoinRPC as BaseBitcoinRPC
from bitcoinrpc._exceptions import RPCError
class BitcoinRPC( BaseBitcoinRPC ):
	async def abatch( self, mp_pairs, **kwargs ):
		response = await self.client.post(
			url = self.url,
			content = orjson.dumps([
					{
						"jsonrpc": "2.0",
						"id": self._counter(),
						"method": mp.pop(0),
						"params": mp,
					}
					for mp in mp_pairs
				]
			),
			**kwargs,
		)
		response.raise_for_status()
		return [
			RPCError(content["error"]["code"], content["error"]["message"])
				if content['error'] else
			content['result']
			for content in orjson.loads(response.content)
		]
## BitcoinRPC Patch End```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions