Skip to content

Latest commit

 

History

History
181 lines (115 loc) · 3.29 KB

Headzoo-Bitcoin-Wallet-Api-RPCPool.md

File metadata and controls

181 lines (115 loc) · 3.29 KB

Headzoo\Bitcoin\Wallet\Api\RPCPool

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");

Properties

$items

The JsonRPCInterface instances in the pool

private Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface[] $items = array()

$count

Number of servers in the pool

private int $count

$index

Index of the last server returned from the pool

private int $index

Methods

Headzoo\Bitcoin\Wallet\Api\RPCPool::add

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)
Arguments

Headzoo\Bitcoin\Wallet\Api\RPCPool::get

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()

Headzoo\Bitcoin\Wallet\Api\RPCPool::count

Returns the number of JsonRPCInterface instances in the pool

public int Headzoo\Bitcoin\Wallet\Api\RPCPool::count()

Headzoo\Bitcoin\Wallet\Api\RPCPool::query

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)
Arguments
  • $method mixed
  • $params array

Headzoo\Bitcoin\Wallet\Api\JsonRPCInterface::query

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)
Arguments
  • $method string - The name of the api method to call
  • $params array - Optional method parameters