当前位置: 首页>>代码示例>>Python>>正文


Python Basic.write_long方法代码示例

本文整理汇总了Python中common.utils.Basic.write_long方法的典型用法代码示例。如果您正苦于以下问题:Python Basic.write_long方法的具体用法?Python Basic.write_long怎么用?Python Basic.write_long使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.utils.Basic的用法示例。


在下文中一共展示了Basic.write_long方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_payment_request_message

# 需要导入模块: from common.utils import Basic [as 别名]
# 或者: from common.utils.Basic import write_long [as 别名]
 def generate_payment_request_message(self):
   """Create a payment request object, store it for later, increase ID, and create the message associated with it
   @returns: str (message for payment request)"""
   #REFACTOR
   cost = self.torApp.get_relay().get_cost()
   interval = self.bank.currentACoinInterval
   #generate ACoin request
   request = BankMessages.make_acoin_request(self.bank, interval, cost)
   request.id = self.currentRequestId
   self.requests[request.id] = request
   self.currentRequestId += 1
   return Basic.write_long(request.id) + request.msg + Globals.PRIVATE_KEY.sign(request.msg)
开发者ID:clawplach,项目名称:BitBlinder,代码行数:14,代码来源:ServerPaymentHandler.py

示例2: send_receipt_message

# 需要导入模块: from common.utils import Basic [as 别名]
# 或者: from common.utils.Basic import write_long [as 别名]
 def send_receipt_message(self, theirId, numTokens):
   """Send a new payment request after a successful payment
   @param theirId:  the id that the origin has associated with this payment
   @type  theirId:  int
   @param numTokens:  how many payment requests to send back to the origin
   @type  numTokens:  int
   @returns:  deferred (triggered when message is done sending)"""
   msg = self.get_prefix()
   msg += Basic.write_long(theirId)
   msg += Basic.write_byte(numTokens)
   for i in range(0, numTokens):
     msg += self.generate_payment_request_message()
   return self.send_direct_tor_message(msg, "receipt", False, 3)
开发者ID:clawplach,项目名称:BitBlinder,代码行数:15,代码来源:ServerPaymentHandler.py

示例3: start_bank_process

# 需要导入模块: from common.utils import Basic [as 别名]
# 或者: from common.utils.Basic import write_long [as 别名]
  def start_bank_process(self, readTokens, writeTokens, paymentId):
    """Create the bank message, and send it to the payment proxy for relaying to the bank.
    @param readTokens:  how many read tokens to pay the merchant for
    @type  readTokens:  int
    @param writeTokens:  how many write tokens to pay the merchant for
    @type  writeTokens:  int
    @param paymentId:  the id for this payment, for tracking when it is completed
    @type  paymentId:  int
    """
    #generate the response message:
    msg  = Basic.write_byte(PAR_VERSION)
    msg += Basic.write_int(readTokens)
    msg += Basic.write_int(writeTokens)
    msg += Basic.write_long(paymentId)
    #figure out how many payments must be made:
    totalTokens = readTokens + writeTokens
    numPayments = totalTokens / Globals.CELLS_PER_PAYMENT
    msg += Basic.write_byte(numPayments)
    bankMsg = Basic.write_byte(numPayments)
    for i in range(0, numPayments):
      #get a token to use for this payment:
      requestId, token = self.paymentTokens.popitem()
      #send it to the bank for signing
      coin = self.parClient.bank.get_acoins(1)
      if not coin:
        paymentDeferred = self.paymentDeferreds[paymentId]
        del self.paymentDeferreds[paymentId]
        paymentDeferred.errback(InsufficientACoins("No ACoins left."))
        return
      coin = coin[0]
      self.parClient.circ.app.coinsSpent += 1
#      log_msg("Srsly, wtf is going on? %s" % (coin.interval), 4)
      bankMsg += coin.write_binary() + token
      msg += Basic.write_byte(COIN_TYPES['A']) + Basic.write_long(requestId)
    key = EncryptedDatagram.ClientSymKey(self.parClient.bank.PUBLIC_KEY)
    bankMsg = Basic.write_byte(1) + key.encrypt(Basic.write_byte(3) + bankMsg)
    msg = Basic.write_byte(PAR_VERSION) + Basic.write_byte(self.hop-1) + Basic.write_lenstr(bankMsg) + Basic.write_lenstr(msg)
    self.parClient.send_direct_tor_message(msg, "bank_relay", True, self.paymentProxyHop)
开发者ID:clawplach,项目名称:BitBlinder,代码行数:40,代码来源:PaymentStream.py


注:本文中的common.utils.Basic.write_long方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。