Manages a pool of JsonRPCInterface instances
Acts as an instance of JsonRPCInterface, which transparently uses a pool of JsonRPCInterface instances to query wallets.
Example:
$pool = new RPCPool();
$conf = [
"user" => "test",
"pass" => "pass",
"host" => "localhost",
"port" => 9332
];
$rpc = new JsonRPC($conf);
$pool->add($rpc);
$conf = [
"user" => "test",
"pass" => "pass",
"host" => "localhost",
"port" => 9333
];
$rpc = new JsonRPC($conf);
$pool->add($rpc);
$info = $pool->query("getinfo");
- Class name: RPCPool
- Namespace: Headzoo\Bitcoin\Wallet\Api
- This class implements: Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface
The JsonRPCInterface instances in the pool
private Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface[] $items = array()
Number of servers in the pool
private int $count
Index of the last server returned from the pool
private int $index
Adds an JsonRPCInterface instance to the pool
public Headzoo\Bitcoin\Wallet\Api\RPCPool Headzoo\Bitcoin\Wallet\Api\RPCPool::add(Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface $rpc)
- $rpc Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface - The JsonRPCInterface instance
Returns an JsonRPCInterface instance from the pool
Returns null when there are no servers in the pool.
public Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface|null Headzoo\Bitcoin\Wallet\Api\RPCPool::get()
Returns the number of JsonRPCInterface instances in the pool
public int Headzoo\Bitcoin\Wallet\Api\RPCPool::count()
Sends a raw query the litecoind rpc
Returns an array which contains the server response.
Example:
$rpc = new JsonRPC();
$info = $rpc->query("getInfo");
echo $info["version"];
echo $info["balance"];
echo $info["difficulty"];
$signature = $rpc->query(
"signMessage",
[
"1Headz2mYtpBRo6KFaaUEtcm5Kce6BZRJM",
"Mary had a little lamb."
]
);
public mixed Headzoo\Bitcoin\Wallet\Api\RPCPool::query($method, array $params)
- $method mixed
- $params array
Sends a raw query the litecoind rpc
Returns an array which contains the server response.
Example:
$rpc = new JsonRPC();
$info = $rpc->query("getInfo");
echo $info["version"];
echo $info["balance"];
echo $info["difficulty"];
$signature = $rpc->query(
"signMessage",
[
"1Headz2mYtpBRo6KFaaUEtcm5Kce6BZRJM",
"Mary had a little lamb."
]
);
public array Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface::query(string $method, array $params)
- This method is defined by Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface
- $method string - The name of the api method to call
- $params array - Optional method parameters