polyswarmclient

Subpackages

Submodules

Package Contents

class polyswarmclient.BidStrategyBase(min_bid_multiplier=None, max_bid_multiplier=None)[source]
class polyswarmclient.NonceManager(client, chain)

Manages the nonce for some Ethereum chain

static find_gaps(nonces)

Finds any gaps between base nonce and the last nonce in the given nonces list.

Parameters

nonces (list[int]) – list of nonces being checked

Returns

(list[int]): Any missing nonces between base_nonce and the last given nonce

exception polyswarmclient.RateLimitedError[source]

Bases: polyswarmclient.exceptions.PolyswarmClientException

Hit the rate limit from polyswarmd

class polyswarmclient.LocalLivenessRecorder[source]

Bases: polyswarmclient.liveness.liveness.LivenessRecorder

Record liveness data in a tempfile

write_sync(self, content)

Write the given content to the file at the given path.

Parameters

content – content to write into the file

class polyswarmclient.BackoffWrapper(func, **kwargs)[source]

Uses a generator to create backoff times

This is for use in functions that don’t return. In our use case, listen_for_events is not supposed to return, but exists as a long running Task. Using the decorator, the backoff time grows forever, because the function is only called one time. So each error causes a longer and longer timeout.

This adds an ability to reset the backoff, so your long running function can reduce the timeout after success

reset(self)
class polyswarmclient.RequestRateLimit(event, lock)[source]
polyswarmclient.logger[source]
polyswarmclient.MAX_ARTIFACTS = 256[source]
polyswarmclient.RATE_LIMIT_SLEEP = 2.0[source]
polyswarmclient.MAX_BACKOFF = 32[source]
class polyswarmclient.Client(polyswarmd_addr, keyfile, password, api_key=None, tx_error_fatal=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?

run(self, chains=None)[source]

Run the main event loop

Parameters

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

clear_sub_clients(self)[source]
create_ethereum_sub_clients(self, chains)[source]
create_fast_sub_clients(self, chains)[source]
static to_wei(amount, unit='ether')[source]
static from_wei(amount, unit='ether')[source]
static _check_status_for_rate_limit(status)[source]
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