Skip to content

Instantly share code, notes, and snippets.

use std::fmt::Display;
use std::fmt::Formatter;
struct A(u64);
impl Display for A {
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(fmt, "{}", self.0)
}
}
# Copyright 2021 Aiven Oy https://aiven.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
from gevent.monkey import patch_all
from gevent.lock import Semaphore
patch_all()
import aiogevent
import asyncio
import gevent
import asyncio
import json
import os
import statistics
from multiprocessing.pool import Pool
import aiohttp
URL = "http://geth.mainnet.ethnodes.brainbot.com:8545"
HEADERS = {
@hackaugusto
hackaugusto / event_fetching.py
Created April 17, 2020 10:54
time response times for geth get logs requests.
import gevent.monkey # isort:skip
gevent.monkey.patch_all() # isort:skip
import statistics
import time
import gevent
from web3 import HTTPProvider, Web3
** playtime (comedy)
* rope
* 1917
* Westworld (1973)
* 10 cloverfield lane
* rififi
* cool hand luke
do the right thing
a most wanted man
the rover
@hackaugusto
hackaugusto / t.py
Created April 14, 2020 15:53
eth_getLogs response time measurment
import time
import raiden_contracts.constants
from eth_utils import to_checksum_address
from raiden_contracts.contract_manager import (ContractManager,
contracts_precompiled_path)
from web3 import HTTPProvider, Web3
from raiden.blockchain.events import BlockchainEvents, filters_to_rpc
from raiden.network.rpc.client import JSONRPCClient
import hashlib
import json
import math
import random
from collections import defaultdict
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Tuple
# Percentage of transfers that should be reused when creating a new block with
# sibilings.
import timeit
setup = "from eth_utils import keccak"
run = "keccak(b'')"
print("keccak")
print(timeit.timeit(run, setup))
setup = "from eth_utils import to_checksum_address"
run = f"to_checksum_address(b'00000000000000000000')"
#!/usr/bin/python
import signal
import gevent
import gevent.event
stop_event = gevent.event.AsyncResult()