Code Monkey home page Code Monkey logo

Comments (8)

UpstreamData avatar UpstreamData commented on July 24, 2024

scan_network_for_miners() will nearly never just scan 1 address. When using it with just 1 IP, it assumes that is a network on that subnet with a subnet mask or /24, meaning if you enter 192.168.1.x, it will search 192.168.1.[1-254]. This is intended as a simplification feature for people less experienced with the way networking works, they may be able to find the IP address of their own computer, but maybe won't understand how their network is structured, so pyasic does the simplest and most common thing for them.

It also attempts a connection beforehand to check if the miner is located at that address, so it opens then immediately closes connections on port 4028, meaning that it will always be slower than get_miner(), as that function is called as part of it but only after the initial connection is accepted.

from pyasic.

UpstreamData avatar UpstreamData commented on July 24, 2024

I can't be sure what your goal is, but a good rule of thumb is that get_miner will always be quicker as scanning is doing more actions then calling get_miner.

If you're writing a program that needs to check beforehand where each miner is in the network, but still needs to be super fast, you can do 2 things:

  • MinerNetwork exposes an async generator with the scan_network_generator method, you can use that with an async for loop to get miners as soon as the program knows they exist, and then use them immediately.

  • get_miner should not error, only return UnknownMiner, so you can just call it on every address you want to check (you can actually use a custom method and a MinerNetwork, just call list(MinerNetwork().get_network().hosts()) and loop through that), then make a check against if not isinstance(miner, UnknownMiner):.

from pyasic.

Awote avatar Awote commented on July 24, 2024

image
i found that timeout for scan_network_for_miner() is 3 seconds, maybe this timeout make scan_network_for_miner() too slow if he ping not a miner and wait 3 second ?

from pyasic.

Awote avatar Awote commented on July 24, 2024

is it bad idea if i decrease this timeout (1 not 3 seconds)?

from pyasic.

UpstreamData avatar UpstreamData commented on July 24, 2024

Nope, decreasing this timeout is fine, that's why its there. Come to think of it I have to come up with a better way to handle that, but for now, you can update those settings at the start of your program by doing:

from pyasic.settings import PyasicSettings

PyasicSettings().ping_timeout = 1
PyasicSettings().network_ping_retries = 1

These default values were there for robustness in the scan, so its possible depending on your miners that the scan could now miss the miners, but for sure tweak and find what works best. I find Whatsminer models are extremely responsive to network requests, so if you have them they will likely not need a large timeout at all.

from pyasic.

Awote avatar Awote commented on July 24, 2024

Thanks for help.
I how another problem, i can't get my miner's wattage value when i use 'get_scan' or 'MinerNetwork'. I allways get -1 . I tested it on one miner and on many miners.
My code for one miner.

    print("test")
    h = time()
    miner = await pyasic.get_miner(ip)
    task = miner.get_data()
    # print(task)
    data = await asyncio.gather(task)
    print(time() - h)
    print(data)
    print("MINER ONE")
    return data.as_json()

What i get :
{'ip': '10.1.50.50', 'datetime': '1675537482', 'mac': '00:00:00:00:00:00', 'model': 'S19j Pro', 'make': 'AntMiner', 'api_ver': '3.7', 'fw_ver': '4.11.1', 'hostname': 'Unknown', 'hashrate': 136.73, 'nominal_hashrate': 136.0, 'hashboards': [{'slot': 0, 'hashrate': 46.62, 'temp': 47, 'chip_temp': 32, 'chips': 126, 'expected_chips': 126, 'missing': False}, {'slot': 1, 'hashrate': 44.88, 'temp': 47, 'chip_temp': 32, 'chips': 126, 'expected_chips': 126, 'missing': False}, {'slot': 2, 'hashrate': 45.22, 'temp': 46, 'chip_temp': 31, 'chips': 126, 'expected_chips': 126, 'missing': False}], 'ideal_hashboards': 3, 'left_board_hashrate': 46.62, 'center_board_hashrate': 44.88, 'right_board_hashrate': 45.22, 'temperature_avg': 47, 'env_temp': -1.0, 'left_board_temp': 47, 'left_board_chip_temp': 32, 'center_board_temp': 47, 'center_board_chip_temp': 32, 'right_board_temp': 46, 'right_board_chip_temp': 31, 'wattage': -1, 'wattage_limit': -1, 'fan_1': 0, 'fan_2': 0, 'fan_3': 0, 'fan_4': 0, 'fan_psu': -1, 'left_chips': 126, 'center_chips': 126, 'right_chips': 126, 'total_chips': 378, 'ideal_chips': 378, 'percent_ideal': 100, 'nominal': True, '...}

from pyasic.

UpstreamData avatar UpstreamData commented on July 24, 2024

Sadly, Antminer models don't provide any wattage measurements, so I have no way of figuring out what the wattage is, and I don't have an algorithm to guess what it might be approximately. Your best bet would be to install BraiinsOS on your miner if it supported, and they have an algorithm that provides a guess at that information. The other option is you could use some sort of smart plug or PDU that would tell you the wattage directly at the wall, and communicate with that, which will give a much more accurate measurement.

Just curious, does wattage show up on the web interface of the miner? If they added it for whatever reason in the newest version or something I could definitely add it, I just have yet to see any way to read that info.

from pyasic.

Awote avatar Awote commented on July 24, 2024

Hi , i check antminer's GUI and don't find any solution for take miners wattage (((

from pyasic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.