IOTAProxy 筆記

Introduction

在 IOTA Tangle 上發起一筆交易,必須歷經以下四個步驟:

  • 簽名 (signature)
  • 驗證 2 個之前的交易 (Tips selection)
  • POW (Attach To Tangle)
  • 廣播 (Broadcast)

其中只有 簽名 (signature) 會在 local (錢包端) 執行,其餘 3 個步驟皆以 Restful API 的方式對 IOTA node 進行 request/response. 而 IOTAProxy(此為 fork 後修改過的版本) 專案利用這個特性,將:驗證 2 個之前的交易 (Tips selection)POW (Attach To Tangle) 等loading 較大的 API 進行轉發.


Edit Me

PS. 官方版的 iotaproxy 專案目的正好與修改過的版本相反,官方版其目的在於將 POW (Attach To Tangle) 以外的所有 API 轉發,POW 則留在 local 端的 node 運作,此為因應 LightWallet 上的 light node 皆不支援 POW (Attach To Tangle) 的關係。

Installation

  • Clone this repository:
    $ git clone https://github.com/TimSamshuijzen/iotaproxy
  • Enter the "iotaproxy" directory:
    $ cd iotaproxy
  • Install dependencies:
    $ npm install

Configuration

Edit index.js to set preferred connection settings. For example:

  • host: proxy target host
  • port: proxy target port
  • localPort: local IRI API port
var iotaProxy = require('./lib/iotaproxy.js');
iotaProxy.start(
  {
    host: 'http://iota.bitfinex.com', 
    port: 80, 
    localPort: 14266,
    overrideAttachToTangle: true
  }
);

Run

Run the proxy server:
$ node index.js

IOTA proxy server started
Listing on port 14266
Relaying requests to iota.bitfinex.com:80  

Test with console Wallet

您可以透過修改一個錢包來確認您的交易是否有真的被 Relay.

Install Wallet

  • Clone Wallet repo.
    $ git clone https://github.com/bahamapascal/CL-Wallet.git

  • Modify to measure POW duration
    $ vi Wallet.py
    Search with api.send_transfer:

    ​​  current_milli_time_0 = datetime.now().microsecond
    
    ​​  api.send_transfer(
    ​​      depth=7,
    ​​      transfers=prepared_transferes,
    ​​      change_address=change_addy,
    ​​      min_weight_magnitude=15
    ​​      )
    
    ​​  current_milli_time_1 = datetime.now().microsecond
    ​​  total_ms = current_milli_time_1 - current_milli_time_0
    
    ​​  print("POW cost " + str(total_ms) + " milliseconds.")
    
    
  • Run
    $ cd CL-Wallet
    $ python Wallet.py

  • Resule

    • ASUS Tinker Board
      iota.adapter.BadApiResponse: 400 response from node: This operations cannot be executed: The subtangle has not been updated yet.
    • Relay to node.deviceproof.org
      Relay: Transaction compleated! Cost: 35116 milliseconds.

Test with Restful API

You can clone all the test script as below from iotaproxy_test_script

Local hardware Relay hardware
ASUS Tinker Board IBM X3550 M4 (7914-IA4)
API Command Local duration(ms) Relay duration(ms)
getNodeInfo 1 0
getNeighbors 5 3
getTips 107 28
findTransactions 3 2
getBalances 2 1
getTransactionsToApprove 38574 1
attachToTangle 8326 190
broadcastTransactions 1057 32

IOTAProxy in i-Certificate Architecture


Edit Me