• 大小: 15.26MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-13
  • 语言: 其他
  • 标签: FPGA  比特比  挖矿  

资源简介

应用于FPGA的挖矿代码,没记错应该是Altera公司de DE2板子。

资源截图

代码片段和文件信息

#!/usr/bin/env python

# by teknohog

# Python wrapper for Xilinx Serial Miner

user = “teknohog.spartan“
password = “nexys2“
host = “api2.bitcoin.cz“
http_port = “8332“

serial_port = “/dev/ttyS0“

askrate = 5

###############################################################################

from jsonrpc import ServiceProxy
from time import ctime sleep time
from serial import Serial
from threading import Thread Event
from Queue import Queue

def stats(count starttime):
    # 2**32 hashes per share (difficulty 1)
    mhshare = 4294.967296

    s = sum(count)
    tdelta = time() - starttime
    rate = s * mhshare / tdelta

    # This is only a rough estimate of the true hash rate
    # particularly when the number of events is low. However since
    # the events follow a Poisson distribution we can estimate the
    # standard deviation (sqrt(n) for n events). Thus we get some idea
    # on how rough an estimate this is.

    # s should always be positive when this function is called but
    # checking for robustness anyway
    if s > 0:
        stddev = rate / s**0.5
    else:
        stddev = 0

    return “[%i accepted %i failed %.2f +/- %.2f Mhash/s]“ % (count[0] count[1] rate stddev)

class Reader(Thread):
    def __init__(self):
        Thread.__init__(self)

        self.daemon = True

        # flush the input buffer
        ser.read(1000)

    def run(self):
        while True:
            nonce = ser.read(4)

            if len(nonce) == 4:
                # Keep this order because writer.block will be
                # updated due to the golden event.
                submitter = Submitter(writer.block nonce)
                submitter.start()
                golden.set()


class Writer(Thread):
    def __init__(self):
        Thread.__init__(self)

        # Keep something sensible available while waiting for the
        # first getwork
        self.block = “0“ * 256
        self.midstate = “0“ * 64

        self.daemon = True

    def run(self):
        while True:
            try:
                work = bitcoin.getwork()
                self.block = work[‘data‘]
                self.midstate = work[‘midstate‘]
            except:
                print(“RPC getwork error“)
                # In this case keep crunching with the old data. It will get 
                # stale at some point but it‘s better than doing nothing.

            # Just a reminder of how Python slices work in reverse
            #rdata = self.block.decode(‘hex‘)[::-1]
            #rdata2 = rdata[32:64]
            rdata2 = self.block.decode(‘hex‘)[95:63:-1]

            rmid = self.midstate.decode(‘hex‘)[::-1]
            
            payload = rmid + rdata2
            
            ser.write(payload)
            
            result = golden.wait(askrate)

            if result:
                golden.clear()

class Submitter(Thread):
    def __init__(self block nonce):
        Thread.__init__(self)

        self.block = block
        self.nonce = 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......       224  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\.gitignore

    .......       815  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\boards\DE2_115\DE2_115.qsf

    .......       832  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\boards\DE2_115\DE2_115.sdc

    .......        25  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\boards\README.md

    .......      1099  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\crc\crc32.v

    .......       783  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\crc\crc32_tb.v

    .......        63  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\crc\simulate.sh

    .......      3766  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\cyclone_iv_pll\hashing_pll.v

    .......        33  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\README.md

    .......       117  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\unoptimized\README.md

    .......      1666  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\unoptimized\sha-256-functions.v

    .......      5140  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\unoptimized\sha256_transform.v

    .......      4855  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\unoptimized_virtual_wire_top.v

    .......      1856  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\cores\virtual_wire\virtual_wire.v

    .......     35147  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\LICENSE.txt

    .......      1292  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\3C120_uart_comm_Test.qpf

    .......     11773  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\3C120_uart_comm_Test.qsf

    .......       106  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\constraints\3C120.sdc

    .......       337  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\hdl\3C120_uart_comm_Test.v

    .......     16055  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\hdl\main_pll.v

    .......        77  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\README.md

    .......     83008  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\stp1.stp

    .......        14  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\3C120_uart_comm_Test\working\.gitignore

    .......      1248  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\BeMicro\fpgaminer.qpf

    .......      4606  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\BeMicro\fpgaminer.qsf

    .......       797  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\BeMicro\fpgaminer.sdc

    .......       235  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\BeMicro\README.md

    .......      5034  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\BeMicro\src\fpgaminer_top.v

    .......      1248  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\DE2_115_makomk_mod\fpgaminer.qpf

    .......      4469  2013-07-17 23:10  Open-Source-FPGA-Bitcoin-Miner-master\projects\DE2_115_makomk_mod\fpgaminer.qsf

............此处省略859个文件信息

评论

共有 条评论