polyswarmclient

Package Contents

class polyswarmclient.BalanceClient(client)[source]

Bases: object

class polyswarmclient.BountiesClient(client)[source]

Bases: object

class polyswarmclient.StakingClient(client)[source]

Bases: object

class polyswarmclient.OffersClient(client)[source]

Bases: object

OffersClient to handle offers. Presently stores a given client and parameters.

class polyswarmclient.RelayClient(client)[source]

Bases: object

class polyswarmclient.NonceManager(client, chain)[source]

Manages the nonce for some Ethereum chain

all_finished(self)

Check that all tasks have finished

mark_update_nonce(self)

Call this when the nonce is out of sync. This sets the update flag to true. The next acquire after being set will trigger an update

polyswarmclient.asyncio_join()[source]
Gather all remaining tasks, assumes loop is not running
polyswarmclient.asyncio_stop()[source]
Stop the main event loop
polyswarmclient.configure_event_loop()[source]
polyswarmclient.exit(exit_status)[source]
Exit the program entirely.
polyswarmclient.MAX_WAIT[source]
polyswarmclient.check_response(response)[source]
Check the status of responses from polyswarmd
Parameters

response – Response dict parsed from JSON from polyswarmd

Returns

True if successful else False

Return type

(bool)

polyswarmclient.is_valid_ipfs_uri(ipfs_uri)[source]
Ensure that a given ipfs_uri is valid by checking length and base58 encoding.
Parameters

ipfs_uri (str) – ipfs_uri to validate

Returns

is this valid?

Return type

bool

polyswarmclient.logger[source]
polyswarmclient.w3[source]
polyswarmclient.REQUEST_TIMEOUT = 300.0[source]
polyswarmclient.MAX_ARTIFACTS = 256[source]
polyswarmclient.RATE_LIMIT_SLEEP = 2.0[source]
class polyswarmclient.Client(polyswarmd_addr, keyfile, password, api_key=None, tx_error_fatal=False, insecure_transport=False)[source]

Bases: object

Client to connected to a Ethereum wallet as well as a polyswarmd instance.

Parameters
  • polyswarmd_addr (str) – URI of polyswarmd you are referring to.

  • keyfile (str) – Keyfile filename.

  • password (str) – Password associated with keyfile.

  • api_key (str) – Your PolySwarm API key.

  • tx_error_fatal (bool) – Transaction errors are fatal and exit the program

  • insecure_transport (bool) – Allow insecure transport such as HTTP?

class __GetArtifacts(client, ipfs_uri, api_key=None)[source]

Bases: object

run(self, chains=None)[source]

Run the main event loop

Parameters

chains (set(str)) – Set of chains to operate on. Defaults to {‘home’, ‘side’}

sign_transactions(self, transactions)[source]

Sign a set of transactions

Parameters

transactions (List[Transaction]) – The transactions to sign

Returns

The signed transactions

Return type

List[Transaction]

static to_wei(amount, unit='ether')[source]
static from_wei(amount, unit='ether')[source]
get_artifacts(self, ipfs_uri, api_key=None)[source]

Get an iterator to return artifacts.

Parameters
  • ipfs_uri (str) – URI where artificats are located

  • api_key (str) – Override default API key

Returns

__GetArtifacts iterator

schedule(self, expiration, event, chain)[source]

Schedule an event to execute on a particular block

Parameters
  • expiration (int) – Which block to execute on

  • event (Event) – Event to trigger on expiration block

  • chain (str) – Which chain to operate on