Author Topic: (Python) latency sorted Bitshares nodes  (Read 627 times)

0 Members and 1 Guest are viewing this topic.

Offline litepresence

  • Full Member
  • ***
  • Posts: 75
    • View Profile
(Python) latency sorted Bitshares nodes
« on: March 11, 2018, 05:53:11 pm »
Update:  Developing here:
https://github.com/litepresence/extinction-event/blob/master/bitshares-node-latency.py







An "official" list of public nodes is here:

https://github.com/bitshares/bitshares-ui/blob/master/app/api/apiConfig.js

you can fetch it like this:
Code: [Select]
def nodes():  # Public Nodes List

    uri = 'https://raw.githubusercontent.com'
    url = uri+'/bitshares/bitshares-ui/master/app/api/apiConfig.js'
    raw = requests.get(url).text
    clean = ((raw.replace('"',"")).replace("'","")).replace(',','')
    parsed = [ t for t in clean.split() if t.startswith('wss') ]
    validated = [i for i in parsed if (('test' not in i) and ('fake' not in i))]

    return validated


result:
Code: [Select]
print (nodes())

>>>
['wss://bitshares.openledger.info/ws', 'wss://eu.openledger.info/ws', 'wss://bit.btsabc.org/ws', 'wss://bts.ai.la/ws', 'wss://bitshares.apasia.tech/ws', 'wss://japan.bitshares.apasia.tech/ws', 'wss://bitshares.dacplay.org/ws', 'wss://bitshares-api.wancloud.io/ws', 'wss://openledger.hk/ws', 'wss://bitshares.crypto.fans/ws', 'wss://ws.gdex.top', 'wss://dex.rnglab.org', 'wss://dexnode.net/ws', 'wss://kc-us-dex.xeldal.com/ws', 'wss://btsza.co.za:8091/ws', 'wss://api.bts.blckchnd.com', 'wss://eu.nodes.bitshares.ws', 'wss://us.nodes.bitshares.ws', 'wss://sg.nodes.bitshares.ws', 'wss://ws.winex.pro']



usage:
Code: [Select]
from bitshares.market import Market
from bitshares import BitShares

BitCURRENCY = 'OPEN.BTC'
BitASSET = 'BTS'
BitPAIR = BitASSET + ":" + BitCURRENCY
MARKET = Market(BitPAIR, bitshares_instance=BitShares(nodes()))

MARKET.buy()
« Last Edit: March 15, 2018, 06:40:32 pm by litepresence »

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 3300
    • View Profile
    • Steemit Blog
  • BitShares: abit
  • GitHub: abitmore
Re: (Python) scraping Bitshares full nodes list from UI repository
« Reply #1 on: March 11, 2018, 06:52:03 pm »
Perhaps it's good tool for pybitshares. Can you make a PR in github? Or even create your own tool set.
BTS account: abit
BTS committee member: abit
BTS witness: in.abit

Online Bangzi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Steemit: Bangzi
  • BitShares: bangzi
Re: (Python) latency sorted nodes from Bitshares UI repository
« Reply #2 on: March 11, 2018, 11:47:58 pm »
print('latency sorted active nodes:')
Please Vote for My Witness: Bangzi
My Blog: https://steemit.com/@bangzi
请投票支持比特股见证人: Bangzi

Offline litepresence

  • Full Member
  • ***
  • Posts: 75
    • View Profile
Re: (Python) scraping Bitshares full nodes list from UI repository
« Reply #3 on: March 13, 2018, 12:07:23 pm »
Perhaps it's good tool for pybitshares. Can you make a PR in github? Or even create your own tool set.

I've decided to maintain my own tool set.

licence.txt

Code: [Select]
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                   Version 0, March 1765

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION:

1) If it bears an official stamp, prepare to throw it overboard.
« Last Edit: March 17, 2018, 12:07:50 am by litepresence »

Offline litepresence

  • Full Member
  • ***
  • Posts: 75
    • View Profile
Re: (Python) latency sorted Bitshares nodes
« Reply #4 on: March 17, 2018, 12:03:24 am »
I've made considerable progress on this script check the github in OP

I've live tested it in a while loop 24 hours and it maintains an output file of latency tested "nodes.txt"

Code: [Select]
def nodes(timeout=20, pings=999999, crop=99, noprint=False, write=False,
          include=False, exclude=False, suffix=True, master=False):

    # timeout : seconds to ping until abort per node
    # pings   : number of good nodes to find until satisfied (0 none, 999 all)
    # suffix  : checks each node for no suffix plus with /ws or /wss
    # noprint : disables printing, only returns list of good nodes
    # master  : check only nodes listed in bitshares/ui/master
    # crop    : return only best nodes
    # write   : maintains an output file nodes.txt with list of best nodes
« Last Edit: March 17, 2018, 02:16:58 am by litepresence »