Class: Lbry::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/lbry/client.rb

Constant Summary collapse

SUPPORTED_METHODS =
%w{
  claim_list_mine
  claim_new_support
  claim_renew
  claim_send_to_address
  claim_show
  cli_test_command
  commands
  daemon_stop
  file_delete
  file_list
  file_reflect
  file_set_status
  get
  help
  peer_list
  peer_ping
  publish
  resolve
  resolve_name
  routing_table_get
  settings_get
  settings_set
  status
  stream_availability
  stream_cost_estimate
  transaction_list
  transaction_show
  utxo_list
  version
  wallet_balance
  wallet_decrypt
  wallet_encrypt
  wallet_is_address_mine
  wallet_list
  wallet_new_address
  wallet_prefill_addresses
  wallet_public_key
  wallet_send
  wallet_unlock
  wallet_unused_address
}.each {|q| self.add_support_for q.to_sym }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth: {}) ⇒ Client

Returns a new instance of Client.



11
12
13
# File 'lib/lbry/client.rb', line 11

def initialize(auth: {})
  @client = Api.new(auth)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/lbry/client.rb', line 4

def client
  @client
end

Class Method Details

.add_support_for(lbry_command, http_verb: :post) ⇒ Object



5
6
7
8
9
# File 'lib/lbry/client.rb', line 5

def self.add_support_for(lbry_command, http_verb: :post)
  define_method(lbry_command) do |*args, &block|
    client.send(http_verb, lbry_command, *args)
  end
end

Instance Method Details

#blob_announce(query) ⇒ Object

Announce blobs to the DHT

Parameters:

  • query (Hash)

Options Hash (query):

  • :blob_hash (String)

    announce a blob, specified by blob_hash

  • :stream_hash (String)

    announce all blobs associated with stream_hash

  • :sd_hash (String)

    announce all blobs associated with sd_hash and the sd_hash itself



21
# File 'lib/lbry/client.rb', line 21

add_support_for :blob_announce

#blob_announce(query) ⇒ Object

Get blob availability

Parameters:

  • query (Hash)

Options Hash (query):

  • :blob_hash (String)

    check availability for this blob hash

  • :search_timeout (Number)

    how long to search for peers for the blob in the dht

  • :sd_hash (Number)

    how long to try downloading from a peer



29
# File 'lib/lbry/client.rb', line 29

add_support_for :blob_availability

#blob_delete(query) ⇒ Object

Delete a blob

Parameters:

  • query (Hash)

Options Hash (query):

  • :blob_hash (String)

    blob hash of the blob to delete



35
# File 'lib/lbry/client.rb', line 35

add_support_for :blob_delete

#blob_get(query) ⇒ Object

Download and return a blob

Parameters:

  • query (Hash)

Options Hash (query):

  • :blob_hash (String)

    :required, blob hash of the blob to get

  • :timeout (Number)

    timeout in number of seconds

  • :encoding (String)

    by default no attempt at decoding is made, can be set to one of the following decoders: ‘json’

  • :payment_rate_manager (String)

    if not given the default payment rate manager will be used. supported alternative rate managers: ‘only-free’



44
# File 'lib/lbry/client.rb', line 44

add_support_for :blob_get

#blob_list(query) ⇒ Object

Returns blob hashes. If not given filters, returns all blobs known by the blob manager

Parameters:

  • query (Hash)

Options Hash (query):

  • :needed (Boolean)

    only return needed blobs

  • :finished (Boolean)

    only return finished blobs

  • :uri (String)

    filter blobs by stream in a uri

  • :stream_hash (String)

    filter blobs by stream hash

  • :sd_hash (String)

    filter blobs by sd hash

  • :page_size (Number)

    results page size

  • :page (Number)

    page of results to return



56
# File 'lib/lbry/client.rb', line 56

add_support_for :blob_list

#blob_reflect(query) ⇒ Object

Returns blob hashes. If not given filters, returns all blobs known by the blob manager

Parameters:

  • query (Hash)

Options Hash (query):

  • :reflector_server (String)

    reflector address



62
# File 'lib/lbry/client.rb', line 62

add_support_for :blob_reflect

#block_show(query) ⇒ Object

Returns blob hashes. If not given filters, returns all blobs known by the blob manager

Parameters:

  • query (Hash)

Options Hash (query):

  • :blockhash (String)

    :required, hash of the block to look up

  • :height (Number)

    :required, height of the block to look up



73
# File 'lib/lbry/client.rb', line 73

add_support_for :block_show

#channel_export(query) ⇒ Object

Export serialized channel signing information for a given certificate claim id

Parameters:

  • query (Hash)

Options Hash (query):

  • :claim_id (String)

    :required, Claim ID to export information about



79
# File 'lib/lbry/client.rb', line 79

add_support_for :channel_export

#channel_import(query) ⇒ Object

Import serialized channel signing information (to allow signing new claims to the channel)

Parameters:

  • query (Hash)

Options Hash (query):

  • :serialized_certificate_info (String)

    :required, certificate info



85
# File 'lib/lbry/client.rb', line 85

add_support_for :channel_import

#channel_new(query) ⇒ Object

Generate a publisher key and create a new ‘@’ prefixed certificate claim

Parameters:

  • query (Hash)

Options Hash (query):

  • :channel_name (String)

    :required, name of the channel prefixed with ‘@’

  • :amount (Float)

    :required, bid amount on the channel



96
# File 'lib/lbry/client.rb', line 96

add_support_for :channel_new

#claim_abandon(query) ⇒ Object

Abandon a name and reclaim credits from the claim

Parameters:

  • query (Hash)

Options Hash (query):

  • :claim_id (String)

    claim_id of the claim to abandon

  • :txid (String)

    txid of the claim to abandon

  • :nout (Number)

    nout of the claim to abandon



104
# File 'lib/lbry/client.rb', line 104

add_support_for :claim_abandon

#claim_list(query) ⇒ Object

List current claims and information about them for a given name

Parameters:

  • query (Hash)

Options Hash (query):

  • :name (String)

    name of the claim to list info about



110
# File 'lib/lbry/client.rb', line 110

add_support_for :claim_list

#claim_list_by_channel(query) ⇒ Object

List current claims and information about them for a given name

Parameters:

  • query (Hash)

Options Hash (query):

  • :uri (String)

    required, uri of the channel

  • :uris (String)

    uris of the channel

  • :page (Number)

    which page of results to return where page 1 is the first page, defaults to no pages

  • :page_size (Number)

    number of results in a page, default of 10



119
# File 'lib/lbry/client.rb', line 119

add_support_for :claim_list_by_channel