Download the PHP package mul53/blzphp without Composer
On this page you can find all versions of the php package mul53/blzphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package blzphp
Short Description Php library that can be used to access the Bluzelle database service.
License MIT
Homepage https://github.com/bluzelle/blzphp
Informations about the package blzphp
blzphp
Installation
You can install this library via Composer: composer require bluzelle/blzphp
Getting Started
In general, you must initialize blzphp before calling any other functions. Do the following using your own configuration parameters as applicable to initialize:
This performs some initial checks, retrieves your account information, and returns an object through which you can call the rest of the API functions.
You may now use the functions described below to perform database operations, as well as retrieve account and status information.
blzphp API documentation
Read below for detailed documentation on how to use the Bluzelle database service.
new Bluzelle\Client({...})
Configures the Bluzelle connection. Multiple clients can be created by creating new instances of this class.
Argument | Description |
---|---|
address | The address of your Bluzelle account |
mnemonic | The mnemonic of the private key for your Bluzelle account |
endpoint | (Optional) The hostname and port of your rest server. Default: http://localhost:1317 |
uuid | (Optional) Bluzelle uses UUID 's to identify distinct databases on a single swarm. We recommend using Version 4 of the universally unique identifier. Defaults to the account address. |
chain_id | (Optional) The chain id of your Bluzelle account. Default: bluzelle |
The calls below are methods of the instance created by instantiating the Bluzelle::Swarm::Client
class.
General Functions
version()
Retrieve the version of the Bluzelle service.
Returns a promise resolving to a string containing the version information, e.g.
Throws an exception if a response is not received from the connection.
account()
Retrieve information about the currently active Bluzelle account.
Returns a promise resolving to a JSON object representing the account information, e.g.
Throws an exception if a response is not received from the connection.
Database Functions
create($key, $value ,$gas_info[, $lease_info])
Create a field in the database.
Argument | Description |
---|---|
key | The name of the key to create |
value | The string value to set the key |
gas_info | Object containing gas parameters (see above) |
lease_info (optional) | Minimum time for key to remain in database (see above) |
Returns a promise resolving to nothing.
Throws an exception when a response is not received from the connection, the key already exists, or invalid value.
read($key, $prove)
Retrieve the value of a key without consensus verification. Can optionally require the result to have a cryptographic proof (slower).
Argument | Description |
---|---|
key | The key to retrieve |
prove | A proof of the value is required from the network (requires 'config trust-node false' to be set) |
Returns a promise resolving the string value of the key.
Throws an exception when the key does not exist in the database. Throws an exception when the prove is true and the result fails verification.
txRead($key, $gas_info)
Retrieve the value of a key via a transaction (i.e. uses consensus).
Argument | Description |
---|---|
key | The key to retrieve |
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving the string value of the key.
Throws an exception when the key does not exist in the database.
update($key, $value , gas_info, lease_info)
Update a field in the database.
Argument | Description |
---|---|
key | The name of the key to create |
value | The string value to set the key |
gas_info | Object containing gas parameters (see above) |
lease_info (optional) | Positive or negative amount of time to alter the lease by. If not specified, the existing lease will not be changed. |
Returns a promise resolving to nothing.
Throws an exception when the key doesn't exist, or invalid value.
delete($key, $gas_info)
Delete a field from the database.
Argument | Description |
---|---|
key | The name of the key to delete |
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to nothing.
Throws an exception when the key is not in the database.
has($key)
Query to see if a key is in the database. This function bypasses the consensus and cryptography mechanisms in favor of speed.
Argument | Description |
---|---|
key | The name of the key to query |
Returns a promise resolving to a boolean value - true
or false
, representing whether the key is in the database.
txHas($key, $gas_info)
Query to see if a key is in the database via a transaction (i.e. uses consensus).
Argument | Description |
---|---|
key | The name of the key to query |
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to a boolean value - true
or false
, representing whether the key is in the database.
keys()
Retrieve a list of all keys. This function bypasses the consensus and cryptography mechanisms in favor of speed.
Returns a promise resolving to an array of strings. ex. ["key1", "key2", ...]
.
txKeys($gas_info)
Retrieve a list of all keys via a transaction (i.e. uses consensus).
Argument | Description |
---|---|
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to an array of strings. ex. ["key1", "key2", ...]
.
rename($key, $new_key, $gas_info)
Change the name of an existing key.
Argument | Description |
---|---|
key | The name of the key to rename |
new_key | The new name for the key |
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to nothing.
Throws an exception if the key doesn't exist.
Argument | Description |
---|---|
key | The name of the key to query |
Returns a promise resolving to a boolean value - true
or false
, representing whether the key is in the database.
count()
Retrieve the number of keys in the current database/uuid. This function bypasses the consensus and cryptography mechanisms in favor of speed.
Returns a promise resolving to an integer value.
txCount($gas_info)
Retrieve the number of keys in the current database/uuid via a transaction.
Argument | Description |
---|---|
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to an integer value.
deleteAll($gas_info)
Remove all keys in the current database/uuid.
Argument | Description |
---|---|
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to nothing.
keyValues()
Enumerate all keys and values in the current database/uuid. This function bypasses the consensus and cryptography mechanisms in favor of speed.
Returns a promise resolving to a JSON array containing key/value pairs, e.g.
txKeyValues($gas_info)
Enumerate all keys and values in the current database/uuid via a transaction.
Argument | Description |
---|---|
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to a JSON array containing key/value pairs, e.g.
multiUpdate($key_values, $gas_info)
Update multiple fields in the database.
Argument | Description |
---|---|
key_values | An array of objects containing keys and values (see example avove) |
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving to nothing.
Throws an exception when any of the keys doesn't exist.
getLease($key)
Retrieve the minimum time remaining on the lease for a key. This function bypasses the consensus and cryptography mechanisms in favor of speed.
Argument | Description |
---|---|
key | The key to retrieve the lease information for |
Returns a promise resolving the minimum length of time remaining for the key's lease, in seconds.
Throws an exception when the key does not exist in the database.
txGetLease($key, $gas_info)
Retrieve the minimum time remaining on the lease for a key, using a transaction.
Argument | Description |
---|---|
key | The key to retrieve the lease information for |
gas_info | Object containing gas parameters (see above) |
Returns a promise resolving the minimum length of time remaining for the key's lease, in seconds.
Throws an exception when the key does not exist in the database.
renew_lease($key, $gas_info, $lease_info)
Update the minimum time remaining on the lease for a key.
Argument | Description |
---|---|
key | The key to retrieve the lease information for |
gas_info | Object containing gas parameters (see above) |
lease_info (optional) | Minimum time for key to remain in database (see above) |
Returns a promise resolving the minimum length of time remaining for the key's lease.
Throws an exception when the key does not exist in the database.
renewLeaseAll($gas_info, $lease_info)
Update the minimum time remaining on the lease for all keys.
Argument | Description |
---|---|
gas_info | Object containing gas parameters (see above) |
lease_info (optional) | Minimum time for key to remain in database (see above) |
Returns a promise resolving the minimum length of time remaining for the key's lease.
Throws an exception when the key does not exist in the database.
getNShortestLease($n)
Retrieve a list of the n keys in the database with the shortest leases. This function bypasses the consensus and cryptography mechanisms in favor of speed.
Argument | Description |
---|---|
n | The number of keys to retrieve the lease information for |
Returns a JSON array of objects containing key, lease (in seconds), e.g.
txGetNShortestLease($n, $gas_info)
Retrieve a list of the N keys/values in the database with the shortest leases, using a transaction.
Argument | Description |
---|---|
n | The number of keys to retrieve the lease information for |
gas_info | Object containing gas parameters (see above) |
Returns a JSON array of objects containing key, lifetime (in seconds), e.g.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to phpgems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mul53/bluzelle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Bluzelle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
All versions of blzphp with dependencies
bitwasp/bech32 Version ^0.0.1
bitwasp/bitcoin Version ^1.0
guzzlehttp/guzzle Version ~6.0
simplito/bn-php Version ^1.1
simplito/elliptic-php Version ^1.0