Exemplo n.º 1
0
def direct_sample(P,
                  d,
                  c=direct_c(np.sqrt(2), 50),
                  alpha=0.85,
                  tol=1.e-3,
                  maxiter=300):
    P = sample2(P, c)
    x, res = pow.pow(P, d, alpha, tol, maxiter)
    return x, res
Exemplo n.º 2
0
    def mine(self, data, lastblock, queue, mined):

        newblock = Block(self.txbuffer[-self.blocksize:], lastblock)
        newblock.nonce, newblock.hash = pow(newblock, self.power)

        # check if another miner/thread has already mined this block
        if not mined.is_set():
            newblock.miner = self.name
            self.reward += 5
            self.txbuffer = []
            self.blockchain.addBlock(newblock)
            queue.put(newblock)

        # set mined event and stop all other threads
        mined.set()
Exemplo n.º 3
0
 def __init__(self):
     genesisblock = Block("block 0")
     genesisblock.nonce, genesisblock.hash = pow(genesisblock, 30)
     self.blocks = [genesisblock]
Exemplo n.º 4
0
 def __init__(self, n=22, seed=0):
     self.liveChallenges = {}
     logger.info("setting up the PoW object... ")
     self.pow = p.pow(n, seed)
     logger.info("done setting up PoW object!")
Exemplo n.º 5
0
 def __init__(self, n = 22, seed = 0):
     self.liveChallenges = {}
     logger.info("setting up the PoW object... ")
     self.pow = p.pow(n, seed)
     logger.info("done setting up PoW object!")
Exemplo n.º 6
0
ABI = [{
    "constant": True,
    "inputs": [],
    "name": "isKing",
    "outputs": [{
        "internalType": "bool",
        "name": "",
        "type": "bool"
    }],
    "payable": False,
    "stateMutability": "pure",
    "type": "function"
}]

r = remote('aab2596ac4a422a9f803ed317089c399b818bb72.balsnctf.com', 30731)
pow(r)


def get_contract():
    r.recvuntil('9:\n')
    data = r.recvline()
    return data


def deploy_contract(data, cur_abi=ABI):
    deet = w3.eth.sendTransaction({'from': w3.eth.accounts[0], 'data': data})
    contract_address = w3.eth.getTransactionReceipt(deet)['contractAddress']
    cntract = w3.eth.contract(abi=cur_abi, address=contract_address)
    return cntract

Exemplo n.º 7
0
def direct_sample(P,d,c=direct_c(np.sqrt(2),50),alpha=0.85,tol=1.e-3,maxiter=300):
    P = sample2(P,c)
    x,res = pow.pow(P,d,alpha,tol,maxiter)
    return x,res