Class: Ipfs::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-ipfs-http-client/client.rb

Overview

The client is not intended to be manipulated. It is a singleton class used to route commands and their corresponding requests.

However, it contains certain, read-only, information that can be useful for debugging purposes.

Constant Summary collapse

DEFAULT_BASE_PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'/api/v0'
CONNECTION_METHODS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[
  Connection::Default,
  Connection::IpfsConfig,
  Connection::Unreachable
]

Class Method Summary collapse

Class Method Details

.daemonHash{Symbol => String}

Various debugging information concerning the running Ipfs daemon and this library

Examples:

Ipfs::Client.daemon
#=> {
  :version: "0.4.13",
  commit: "cc01b7f",
  repo: "6",
  system: "amd64/darwin",
  golang: "go1.9.2"
}

Returns:

  • (Hash{Symbol => String})


82
83
84
# File 'lib/ruby-ipfs-http-client/client.rb', line 82

def daemon
  @@daemon
end

.execute(command, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/ruby-ipfs-http-client/client.rb', line 41

def execute(command, *args)
  command.parse_response call command.build_request *args
end

.idHash{Symbol => String, Array<String>}

Various debugging information concerning the Ipfs node itself

Examples:

Ipfs::Client.id
#=> {
  peer_id: 'QmVnLbr9Jktjwx...',
  addresses: [
    "/ip4/127.0.0.1/tcp/4001/ipfs/QmVwxnW4Z8JVMDfo1jeFMNqQor5naiStUPooCdf2Yu23Gi",
    "/ip4/192.168.1.16/tcp/4001/ipfs/QmVwxnW4Z8JVMDfo1jeFMNqQor5naiStUPooCdf2Yu23Gi",
    "/ip6/::1/tcp/4001/ipfs/QmVwxnW4Z8JVMDfo1jeFMNqQor5naiStUPooCdf2Yu23Gi",
    "/ip6/2a01:e34:ef8d:2940:8f7:c616:...5naiStUPooCdf2Yu23Gi",
    "/ip6/2a01:e34:ef8d:2940:...5naiStUPooCdf2Yu23Gi",
    "/ip4/78.248.210.148/tcp/13684/ipfs/Qm...o1jeFMNqQor5naiStUPooCdf2Yu23Gi"
  ],
  public_key: "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwgg...AgMBAAE=",
  agent_version: "go-ipfs/0.4.13/3b16b74"
}

Returns:

  • (Hash{Symbol => String, Array<String>})


64
65
66
# File 'lib/ruby-ipfs-http-client/client.rb', line 64

def id
  @@id
end

.initializeObject



30
31
32
33
34
35
36
37
# File 'lib/ruby-ipfs-http-client/client.rb', line 30

def initialize
  attempt_connection

  retrieve_ids
  retrieve_daemon_version

  ObjectSpace.define_finalizer(self, proc { @@connection.close })
end