desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Create an empty next block. :param database: the database to use as information source :param transaction: the transaction to use in this block :param public_key: the public key to use for this block :param link: optionally create the block as a linked block to this block :param link_pk: the public key of the counterp...
@classmethod def create(cls, transaction, database, public_key, link=None, link_pk=None):
blk = database.get_latest(public_key) ret = cls() if link: ret.transaction = link.transaction ret.link_public_key = link.public_key ret.link_sequence_number = link.sequence_number else: ret.transaction = transaction ret.link_public_key = link_pk if blk: ...
'Encode this block for transport :param signature: False to pack EMPTY_SIG in the signature location, true to pack the signature field :return: the buffer the data was packed into'
def pack(self, signature=True):
encoded_tx = encode(self.transaction) buff = bytearray(block_pack_size) pack_into(block_pack_format, buff, 0, self.public_key, self.sequence_number, self.link_public_key, self.link_sequence_number, self.previous_hash, (self.signature if signature else EMPTY_SIG)) return ((str(buff) + struct.pack('!I', l...
'Unpacks a block from a buffer :param data: The buffer to unpack from :param offset: Optionally, the offset at which to start unpacking :return: The TrustChainBlock that was unpacked from the buffer'
@classmethod def unpack(cls, data, offset=0):
ret = TrustChainBlock() (ret.public_key, ret.sequence_number, ret.link_public_key, ret.link_sequence_number, ret.previous_hash, ret.signature) = unpack_from(block_pack_format, data, offset) offset += block_pack_size (tx_len,) = struct.unpack('!I', data[offset:(offset + 4)]) offset += 4 (_, ret.t...
'Prepare a tuple to use for inserting into the database :return: A database insertable tuple'
def pack_db_insert(self):
return (buffer(encode(self.transaction)), buffer(self.public_key), self.sequence_number, buffer(self.link_public_key), self.link_sequence_number, buffer(self.previous_hash), buffer(self.signature), buffer(self.hash))
'This override allows one to take the dict(<block>) of a block. :return: generator to iterate over all properties of this block'
def __iter__(self):
for (key, value) in self.__dict__.iteritems(): if (key == 'key'): continue if (isinstance(value, basestring) and (key != 'insert_time')): (yield (key, value.encode('hex'))) else: (yield (key, value)) (yield ('hash', self.hash.encode('hex')))
'The block does not violate any rules'
@staticmethod def valid():
pass
'The block does not violate any rules, but there are gaps or no blocks on the previous or next block'
@staticmethod def partial():
pass
'The block does not violate any rules, but there is a gap or no block on the next block'
@staticmethod def partial_next():
pass
'The block does not violate any rules, but there is a gap or no block on the previous block'
@staticmethod def partial_previous():
pass
'There are no blocks (previous or next) to validate against'
@staticmethod def no_info():
pass
'The block violates at least one validation rule'
@staticmethod def invalid():
pass
'Setup all message that can be received by this community and the super classes. :return: list of meta messages.'
def initiate_meta_messages(self):
return (super(TrustChainCommunity, self).initiate_meta_messages() + [Message(self, HALF_BLOCK, NoAuthentication(), PublicResolution(), DirectDistribution(), CandidateDestination(), HalfBlockPayload(), self._generic_timeline_check, self.received_half_block), Message(self, CRAWL, MemberAuthentication(), PublicResolut...
'Return whether we should sign the block in the passed message. @param message: the message containing a block we want to sign or not.'
def should_sign(self, message):
return True
'Returns a Deferred that fires when we receive an introduction response from a given candidate.'
def wait_for_intro_of_candidate(self, candidate):
response_deferred = Deferred() self.expected_intro_responses[candidate.sock_addr] = response_deferred return response_deferred
'Returns a Deferred that fires when we receive a signature request with a specific block hash.'
def wait_for_signature_request(self, block_id):
if (block_id in self.received_block_ids): return succeed(None) response_deferred = Deferred() self.expected_sig_requests[block_id] = response_deferred return response_deferred
'Create, sign, persist and send a block signed message :param candidate: The peer with whom you have interacted, as a dispersy candidate :param transaction: A string describing the interaction in this block :param linked: The block that the requester is asking us to sign'
def sign_block(self, candidate, public_key=None, transaction=None, linked=None):
assert (((transaction is None) and (linked is not None)) or ((transaction is not None) and (linked is None))), 'Either provide a linked block or a transaction, not both' assert ((linked is None) or (linked.link_public_key == self.my_member.public_key)), 'Cannot counter sign b...
'We\'ve received a half block, either because we sent a SIGNED message to some one or we are crawling :param messages The half block messages'
def received_half_block(self, messages):
self.logger.debug('Received %d half block messages.', len(messages)) for message in messages: blk = message.payload.block validation = blk.validate(self.persistence) self.logger.debug('Block validation result %s, %s, (%s)', validation[0], validation[1], blk) ...
'Set the callback function for live edge updates. Passed arguments are: live_edge_id, [candidates]'
def set_live_edge_callback(self, func):
self._live_edge_cb = func
'Reset the live edges counter and current live edge.'
def reset_live_edges(self):
self._live_edge = [] self._live_edge_next = None self._live_edge_id = 0
'Enable or disable live edges. :param value: whether or not to enable live edges :type value: boolean'
def set_live_edges_enabled(self, value):
if (value and (not self._live_edges_enabled)): self.reset_live_edges() self._live_edges_enabled = value
'Get the trust for another member. Currently this is just the length of their chain. :param member: the member we interacted with :type member: dispersy.member.Member :return: the trust value for this member :rtype: int'
def get_trust(self, member):
block = self.persistence.get_latest(member.public_key) if block: return block.sequence_number else: return 1
'Choose a trusted candidate to introduce to someone else. The more trust you have for someone, the higher the chance is to forward them.'
def dispersy_get_introduce_candidate(self, exclude_candidate=None):
if (not self._live_edges_enabled): return super(TrustChainCommunity, self).dispersy_get_introduce_candidate(exclude_candidate) eligible = [candidate for candidate in self._candidates.itervalues() if (candidate.get_member() and (candidate != exclude_candidate))] if (not eligible): return supe...
':param order_book: The order book to search in :type order_book: OrderBook'
def __init__(self, order_book):
super(MatchingStrategy, self).__init__() self._logger = logging.getLogger(self.__class__.__name__) assert isinstance(order_book, OrderBook), type(order_book) self.order_book = order_book
':param order: The order to match against :type order: Order :return: The proposed trades :rtype: [ProposedTrade]'
@abstractmethod def match_order(self, order):
return
':param order: The order to match against :type order: Order :return: The proposed trades :rtype: [ProposedTrade]'
def match_order(self, order):
assert isinstance(order, Order), type(order) if order.is_ask(): (quantity_to_trade, proposed_trades) = self._match_ask(order) else: (quantity_to_trade, proposed_trades) = self._match_bid(order) if (quantity_to_trade > Quantity(0, quantity_to_trade.wallet_id)): self._logger.debug(...
'Search through the price levels in the order book :param price: The price of the price level :param price_level: The price level to search in :param quantity_to_trade: The quantity still to be matched :param order: The order to match for :type price: Price :type price_level: PriceLevel :type quantity_to_trade: Quantit...
def _search_for_quantity_in_order_book(self, price, price_level, quantity_to_trade, order):
if (price_level is None): return (quantity_to_trade, []) assert isinstance(price, Price), type(price) assert isinstance(price_level, PriceLevel), type(price_level) assert isinstance(quantity_to_trade, Quantity), type(quantity_to_trade) assert isinstance(order, Order), type(order) self._l...
'Search through the tick entries in the price levels :param tick_entry: The tick entry to match against :param quantity_to_trade: The quantity still to be matched :param order: The order to match for :type tick_entry: TickEntry :type quantity_to_trade: Quantity :type order: Order :return: The quantity to trade and the ...
def _search_for_quantity_in_price_level(self, tick_entry, quantity_to_trade, order):
if (tick_entry is None): return (quantity_to_trade, []) if (order.order_id.trader_id == tick_entry.order_id.trader_id): return (quantity_to_trade, []) assert isinstance(tick_entry, TickEntry), type(tick_entry) assert isinstance(quantity_to_trade, Quantity), type(quantity_to_trade) as...
':param matching_strategy: The strategy to use :type matching_strategy: MatchingStrategy'
def __init__(self, matching_strategy):
super(MatchingEngine, self).__init__() self._logger = logging.getLogger(self.__class__.__name__) assert isinstance(matching_strategy, MatchingStrategy), type(matching_strategy) self.matching_strategy = matching_strategy
':param order: The order to match against :type order: Order :return: The proposed trades :rtype: [ProposedTrade]'
def match_order(self, order):
assert isinstance(order, Order), type(order) now = time() proposed_trades = self.matching_strategy.match_order(order) diff = (time() - now) self._logger.debug('Matching engine completed in %.2f seconds', diff) return proposed_trades
':param order_number: Integer representing the number of an order :type order_number: int :raises ValueError: Thrown when one of the arguments are invalid'
def __init__(self, order_number):
super(OrderNumber, self).__init__() if (not isinstance(order_number, (int, long))): raise ValueError('Order number must be an integer or long') self._order_number = order_number
':param trader_id: The trader id who created the order :param order_number: The number of the order created :type trader_id: TraderId :type order_number: OrderNumber'
def __init__(self, trader_id, order_number):
super(OrderId, self).__init__() assert isinstance(trader_id, TraderId), type(trader_id) assert isinstance(order_number, OrderNumber), type(order_number) self._trader_id = trader_id self._order_number = order_number
':rtype: TraderId'
@property def trader_id(self):
return self._trader_id
':rtype: OrderNumber'
@property def order_number(self):
return self._order_number
'format: <trader_id>.<order_number>'
def __str__(self):
return ('%s.%s' % (self._trader_id, self._order_number))
':param order_id: An order id to identify the order :param price: A price to indicate for which amount to sell or buy :param quantity: A quantity to indicate how much to sell or buy :param timeout: A timeout when this tick is going to expire :param timestamp: A timestamp when the order was created :param is_ask: A bool...
def __init__(self, order_id, price, quantity, timeout, timestamp, is_ask):
super(Order, self).__init__() self._logger = logging.getLogger(self.__class__.__name__) assert isinstance(order_id, OrderId), type(order_id) assert isinstance(price, Price), type(price) assert isinstance(quantity, Quantity), type(quantity) assert isinstance(timeout, Timeout), type(timeout) a...
'Create an Order object based on information in the database.'
@classmethod def from_database(cls, data, reserved_ticks):
(trader_id, order_number, price, price_type, quantity, quantity_type, traded_quantity, timeout, order_timestamp, completed_timestamp, is_ask, cancelled) = data order_id = OrderId(TraderId(str(trader_id)), OrderNumber(order_number)) order = cls(order_id, Price(price, str(price_type)), Quantity(quantity, str(...
'Returns a database representation of an Order object. :rtype: tuple'
def to_database(self):
completed_timestamp = (float(self.completed_timestamp) if self.completed_timestamp else None) return (unicode(self.order_id.trader_id), unicode(self.order_id.order_number), float(self.price), unicode(self.price.wallet_id), float(self.total_quantity), unicode(self.total_quantity.wallet_id), float(self.traded_qua...
':rtype: Dictionary[OrderId: Quantity]'
@property def reserved_ticks(self):
return self._reserved_ticks
':rtype: OrderId'
@property def order_id(self):
return self._order_id
':rtype: Price'
@property def price(self):
return self._price
'Return the total quantity of the order :rtype: Quantity'
@property def total_quantity(self):
return self._quantity
'Return the quantity that is not reserved :rtype: Quantity'
@property def available_quantity(self):
self._logger.debug('quantity: %s, reserved: %s, traded: %s', self._quantity, self._reserved_quantity, self._traded_quantity) return ((self._quantity - self._reserved_quantity) - self._traded_quantity)
'Return the reserved quantity of the order :rtype: Quantity'
@property def reserved_quantity(self):
return self._reserved_quantity
'Return the traded quantity of the order :rtype: Quantity'
@property def traded_quantity(self):
return self._traded_quantity
'Return when the order is going to expire :rtype: Timeout'
@property def timeout(self):
return self._timeout
':rtype: Timestamp'
@property def timestamp(self):
return self._timestamp
':return: the timestamp of completion of this order, None if this order is not completed (yet). :rtype: Timestamp'
@property def completed_timestamp(self):
return self._completed_timestamp
':return: True if message is an ask, False otherwise :rtype: bool'
def is_ask(self):
return self._is_ask
':return: whether the order has been cancelled or not. :rtype: bool'
@property def cancelled(self):
return self._cancelled
':return: True if the order is completed. :rtype: bool'
def is_complete(self):
return (self._traded_quantity >= self._quantity)
'Return the status of this order. Can be one of these: "open", "completed", "expired" or "cancelled" :return: The status of this order :rtype: str'
@property def status(self):
if self._cancelled: return 'cancelled' elif self.is_complete(): return 'completed' elif self._timeout.is_timed_out(self._timestamp): return 'expired' return 'open'
':param order_id: The order id from another peer that the quantity needs to be reserved for :param quantity: The quantity to reserve :type order_id: OrderId :type quantity: Quantity :return: True if the quantity was reserved, False otherwise :rtype: bool'
def reserve_quantity_for_tick(self, order_id, quantity):
assert isinstance(order_id, OrderId), type(order_id) assert isinstance(quantity, Quantity), type(quantity) if (self.available_quantity >= quantity): self._reserved_quantity += quantity if (order_id not in self._reserved_ticks): self._reserved_ticks[order_id] = quantity el...
'Release all quantity for a specific tick. :param order_id: The order id from another peer that the quantity needs to be released for :type order_id: OrderId :raises TickWasNotReserved: Thrown when the tick was not reserved first'
def release_quantity_for_tick(self, order_id, quantity):
if (order_id not in self._reserved_ticks): raise TickWasNotReserved() if (self._reserved_quantity >= quantity): self._reserved_quantity -= quantity self._reserved_ticks[order_id] -= quantity assert (self.available_quantity >= Quantity(0, self._quantity.wallet_id)), str(self.avail...
':return: True if valid, False otherwise :rtype: bool'
def is_valid(self):
return ((not self._timeout.is_timed_out(self._timestamp)) and (not self._cancelled))
'Return a dictionary representation of this dictionary.'
def to_dictionary(self):
completed_timestamp = (float(self.completed_timestamp) if self.completed_timestamp else None) return {'trader_id': str(self.order_id.trader_id), 'order_number': int(self.order_id.order_number), 'price': float(self.price), 'price_type': self.price.wallet_id, 'quantity': float(self.total_quantity), 'quantity_type...
':param payment_id: String representation of the id of the payment :type payment_id: str :raises ValueError: Thrown when one of the arguments are invalid'
def __init__(self, payment_id):
super(PaymentId, self).__init__() if (not isinstance(payment_id, str)): raise ValueError('Payment id must be a string') self._payment_id = payment_id
'Return the payment id.'
@property def payment_id(self):
return self._payment_id
'Don\'t use this class directly, use one of the class methods :param message_id: A message id to identify the tick :param order_id: A order id to identify the order this tick represents :param price: A price to indicate for which amount to sell or buy :param quantity: A quantity to indicate how much to sell or buy :par...
def __init__(self, message_id, order_id, price, quantity, timeout, timestamp, is_ask, public_key=EMPTY_PK, signature=EMPTY_SIG):
super(Tick, self).__init__(message_id, timestamp) assert isinstance(order_id, OrderId), type(order_id) assert isinstance(price, Price), type(price) assert isinstance(quantity, Quantity), type(quantity) assert isinstance(timeout, Timeout), type(timeout) assert isinstance(public_key, str), type(pu...
'Create a tick from an order :param order: The order that this tick represents :param message_id: The message id for the tick :return: The created tick :rtype: Tick'
@classmethod def from_order(cls, order, message_id):
assert isinstance(order, Order), type(order) assert isinstance(message_id, MessageId), type(message_id) if order.is_ask(): return Ask(message_id, order.order_id, order.price, (order.total_quantity - order.traded_quantity), order.timeout, order.timestamp) else: return Bid(message_id, orde...
':rtype: OrderId'
@property def order_id(self):
return self._order_id
':rtype: Price'
@property def price(self):
return self._price
':rtype: Quantity'
@property def quantity(self):
return self._quantity
':param quantity: The new quantity :type quantity: Quantity'
@quantity.setter def quantity(self, quantity):
assert isinstance(quantity, Quantity), type(quantity) self._quantity = quantity
'Return when the tick is going to expire :rtype: Timeout'
@property def timeout(self):
return self._timeout
':return: True if this tick is an ask, False otherwise :rtype: bool'
def is_ask(self):
return self._is_ask
':return: True if valid, False otherwise :rtype: bool'
def is_valid(self):
return ((not self._timeout.is_timed_out(self._timestamp)) and (time.time() >= (float(self.timestamp) - self.TIME_TOLERANCE)))
'Sign this tick using a private key. :param member: The member that signs this tick'
def sign(self, member):
crypto = ECCrypto() self._public_key = member.public_key self._signature = crypto.create_signature(member.private_key, self.get_sign_data())
'Update the timestamp of this tick and set it to the current time.'
def update_timestamp(self):
self._timestamp = Timestamp.now()
'Return network representation of the tick'
def to_network(self):
return (self._order_id.trader_id, self._message_id.message_number, self._order_id.order_number, self._price, self._quantity, self._timeout, self._timestamp, self._public_key, self._signature)
'Return a dictionary with a representation of this tick.'
def to_dictionary(self):
return {'trader_id': str(self.order_id.trader_id), 'order_number': int(self.order_id.order_number), 'message_id': str(self.message_id), 'price': float(self.price), 'price_type': self.price.wallet_id, 'quantity': float(self.quantity), 'quantity_type': self.quantity.wallet_id, 'timeout': float(self.timeout), 'timesta...
':param message_id: A message id to identify the ask :param order_id: A order id to identify the order this tick represents :param price: A price that needs to be paid for the ask :param quantity: The quantity that needs to be sold :param timeout: A timeout for the ask :param timestamp: A timestamp for when the ask was...
def __init__(self, message_id, order_id, price, quantity, timeout, timestamp, public_key=EMPTY_PK, signature=EMPTY_SIG):
super(Ask, self).__init__(message_id, order_id, price, quantity, timeout, timestamp, True, public_key, signature)
'Restore an ask from the network :param data: OfferPayload :return: Restored ask :rtype: Ask'
@classmethod def from_network(cls, data):
assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'order_number'), isinstance(data.order_number, OrderNumber) assert hasattr(data, 'price'), isinstance(data.price, Price) ...
':param message_id: A message id to identify the bid :param order_id: A order id to identify the order this tick represents :param price: A price that you are willing to pay for the bid :param quantity: The quantity that you want to buy :param timeout: A timeout for the bid :param timestamp: A timestamp for when the bi...
def __init__(self, message_id, order_id, price, quantity, timeout, timestamp, public_key=EMPTY_PK, signature=EMPTY_SIG):
super(Bid, self).__init__(message_id, order_id, price, quantity, timeout, timestamp, False, public_key, signature)
'Restore a bid from the network :param data: OfferPayload :return: Restored bid :rtype: Bid'
@classmethod def from_network(cls, data):
assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'order_number'), isinstance(data.order_number, OrderNumber) assert hasattr(data, 'price'), isinstance(data.price, Price) ...
'Do not use this class directly Make a subclass of this class with a specific implementation for a storage backend'
def __init__(self):
super(TransactionRepository, self).__init__() self._logger = logging.getLogger(self.__class__.__name__)
':param mid: Hex encoded version of the member id of this node :type mid: str'
def __init__(self, mid):
super(MemoryTransactionRepository, self).__init__() self._logger.info('Memory transaction repository used') self._mid = mid self._next_id = 0 self._transactions = {}
':rtype: [Transaction]'
def find_all(self):
return self._transactions.values()
':param transaction_id: The transaction id to look for :type transaction_id: TransactionId :return: The transaction or null if it cannot be found :rtype: Transaction'
def find_by_id(self, transaction_id):
assert isinstance(transaction_id, TransactionId), type(transaction_id) self._logger.debug((('Transaction with the id: ' + str(transaction_id)) + ' was searched for in the transaction repository')) return self._transactions.get(transaction_id)
':type transaction: Transaction'
def add(self, transaction):
assert isinstance(transaction, Transaction), type(transaction) self._logger.debug((('Transaction with the id: ' + str(transaction.transaction_id)) + ' was added to the transaction repository')) self._transactions[transaction.transaction_id] = transaction
':type transaction: Transaction'
def update(self, transaction):
assert isinstance(transaction, Transaction), type(transaction) self._logger.debug((('Transaction with the id: ' + str(transaction.transaction_id)) + ' was updated to the transaction repository')) self._transactions[transaction.transaction_id] = transaction
':type transaction_id: TransactionId'
def delete_by_id(self, transaction_id):
assert isinstance(transaction_id, TransactionId), type(transaction_id) self._logger.debug((('Transaction with the id: ' + str(transaction_id)) + ' was deleted from the transaction repository')) del self._transactions[transaction_id]
':rtype: TransactionId'
def next_identity(self):
self._next_id += 1 return TransactionId(TraderId(self._mid), TransactionNumber(self._next_id))
':param mid: Hex encoded version of the member id of this node :type mid: str'
def __init__(self, mid, persistence):
super(DatabaseTransactionRepository, self).__init__() self._logger.info('Database transaction repository used') self._mid = mid self.persistence = persistence
':rtype: [Transaction]'
def find_all(self):
return self.persistence.get_all_transactions()
':param transaction_id: The transaction id to look for :type transaction_id: TransactionId :return: The transaction or null if it cannot be found :rtype: Transaction'
def find_by_id(self, transaction_id):
assert isinstance(transaction_id, TransactionId), type(transaction_id) self._logger.debug('Transaction with the id: %s was searched for in the transaction repository', str(transaction_id)) return self.persistence.get_transaction(transaction_id)
':param transaction: The transaction to add to the database :type transaction: Transaction'
def add(self, transaction):
self.persistence.add_transaction(transaction)
':param transaction: The transaction to update :type transaction: Transaction'
def update(self, transaction):
self.delete_by_id(transaction.transaction_id) self.add(transaction)
':param transaction_id: The id of the transaction to remove'
def delete_by_id(self, transaction_id):
self.persistence.delete_transaction(transaction_id)
':rtype: TransactionId'
def next_identity(self):
return TransactionId(TraderId(self._mid), TransactionNumber(self.persistence.get_next_transaction_number()))
':param timeout: Float representation of a timeout :type timeout: float :raises ValueError: Thrown when one of the arguments are invalid'
def __init__(self, timeout):
super(Timeout, self).__init__() if (not isinstance(timeout, (float, int, long))): raise ValueError('Timeout must be a float, integer or long') if (timeout < 0): raise ValueError('Timeout must be positive or zero') self._timeout = timeout
'Return if a timeout has occurred :param timestamp: A timestamp :type timestamp: Timestamp :return: True if timeout has occurred, False otherwise :rtype: bool'
def is_timed_out(self, timestamp):
assert isinstance(timestamp, Timestamp), type(timestamp) return ((time.time() - float(timestamp)) >= self._timeout)
':param quantity: float representation of a quantity that is positive or zero :param wallet_id: Identifier of the wallet type of this price :type quantity: float :type wallet_id: str :raises ValueError: Thrown when one of the arguments are invalid'
def __init__(self, quantity, wallet_id):
super(Quantity, self).__init__() if (not isinstance(quantity, (int, float))): raise ValueError('Quantity must be an int or a float') if (quantity < 0): raise ValueError(('Quantity must be positive or zero, not %f' % quantity)) if (not isinstance(...
':rtype: str'
@property def wallet_id(self):
return self._wallet_id
':rtype: int'
@property def int_wallet_id(self):
return ASSET_MAP[self._wallet_id]
'Create a Payment object based on information in the database.'
@classmethod def from_database(cls, data):
(trader_id, message_number, transaction_trader_id, transaction_number, payment_id, transferee_quantity, quantity_type, transferee_price, price_type, address_from, address_to, timestamp, success) = data message_id = MessageId(TraderId(str(trader_id)), MessageNumber(str(message_number))) transaction_id = Tran...
'Returns a database representation of a Payment object. :rtype: tuple'
def to_database(self):
return (unicode(self.message_id.trader_id), unicode(self.message_id.message_number), unicode(self.transaction_id.trader_id), int(self.transaction_id.transaction_number), unicode(self.payment_id), float(self.transferee_quantity), unicode(self.transferee_quantity.wallet_id), float(self.transferee_price), unicode(self...
'Restore a payment from the network :param data: PaymentPayload :return: Restored payment :rtype: Payment'
@classmethod def from_network(cls, data):
assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'transaction_trader_id'), isinstance(data.transaction_trader_id, TraderId) assert hasattr(data, 'transaction_number'), isins...
'Return network representation of the multi chain payment'
def to_network(self):
return (self._message_id.trader_id, self._message_id.message_number, self._transaction_id.trader_id, self._transaction_id.transaction_number, self._transferee_quantity, self._transferee_price, self._address_from, self._address_to, self._payment_id, self._timestamp, self._success)
':type ask: Ask'
def insert_ask(self, ask):
assert isinstance(ask, Ask), type(ask) if ((not self._asks.tick_exists(ask.order_id)) and ask.is_valid()): self._asks.insert_tick(ask) timeout_delay = ((float(ask.timestamp) + float(ask.timeout)) - time.time()) task = deferLater(reactor, timeout_delay, self.timeout_ask, ask.order_id) ...
':type order_id: OrderId'
def remove_ask(self, order_id):
assert isinstance(order_id, OrderId), type(order_id) if self._asks.tick_exists(order_id): self.cancel_pending_task(('ask_%s_timeout' % order_id)) self._asks.remove_tick(order_id)