Skip to content

Commit 64a0d8d

Browse files
committed
Remove some unused imports (and address black formatting as pointed by CI). Addresses issue Chia-Network#286.
1 parent f238c55 commit 64a0d8d

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

pool/pool.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from chia.types.blockchain_format.proof_of_space import verify_and_get_quality_string
2727
from chia.types.coin_record import CoinRecord
2828
from chia.types.coin_spend import CoinSpend
29-
from chia.types.spend_bundle import SpendBundle
3029
from chia.util.bech32m import decode_puzzle_hash
3130
from chia.consensus.constants import ConsensusConstants
3231
from chia.util.ints import uint8, uint16, uint32, uint64

pool/pool_server.py

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def get_ssl_context(config):
6161

6262
class PoolServer:
6363
def __init__(self, config: Dict, constants: ConsensusConstants, pool_store: Optional[AbstractPoolStore] = None):
64-
6564
# We load our configurations from here
6665
with open(os.getcwd() + "/config.yaml") as f:
6766
pool_config: Dict = yaml.safe_load(f)

pool/singleton.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from chia.rpc.wallet_rpc_client import WalletRpcClient
1818
from chia.types.announcement import Announcement
1919
from chia.types.blockchain_format.coin import Coin
20-
from chia.types.blockchain_format.program import Program, SerializedProgram
20+
from chia.types.blockchain_format.program import Program
2121
from chia.types.blockchain_format.sized_bytes import bytes32
2222
from chia.types.coin_record import CoinRecord
2323
from chia.types.coin_spend import CoinSpend

pool/store/mariadb_store.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import os
22
import yaml
33
import logging
4-
from pathlib import Path
54
from typing import Optional, Set, List, Tuple, Dict
65

7-
import asyncio
86
import aiomysql
97
import pymysql
108
from blspy import G1Element
@@ -94,7 +92,7 @@ def _row_to_farmer_record(row) -> FarmerRecord:
9492
)
9593

9694
async def add_farmer_record(self, farmer_record: FarmerRecord, metadata: RequestMetadata):
97-
with (await self.pool) as connection:
95+
with await self.pool as connection:
9896
cursor = await connection.cursor()
9997
await cursor.execute(
10098
f"INSERT INTO farmer VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) "
@@ -127,7 +125,7 @@ async def add_farmer_record(self, farmer_record: FarmerRecord, metadata: Request
127125

128126
async def get_farmer_record(self, launcher_id: bytes32) -> Optional[FarmerRecord]:
129127
# TODO(pool): use cache
130-
with (await self.pool) as connection:
128+
with await self.pool as connection:
131129
cursor = await connection.cursor()
132130
await cursor.execute(
133131
f"SELECT * FROM farmer WHERE launcher_id=%s",
@@ -139,7 +137,7 @@ async def get_farmer_record(self, launcher_id: bytes32) -> Optional[FarmerRecord
139137
return self._row_to_farmer_record(row)
140138

141139
async def update_difficulty(self, launcher_id: bytes32, difficulty: uint64):
142-
with (await self.pool) as connection:
140+
with await self.pool as connection:
143141
connection = await self.pool.acquire()
144142
cursor = await connection.cursor()
145143
await cursor.execute(
@@ -155,7 +153,7 @@ async def update_singleton(
155153
is_pool_member: bool,
156154
):
157155
entry = (bytes(singleton_tip), bytes(singleton_tip_state), int(is_pool_member), launcher_id.hex())
158-
with (await self.pool) as connection:
156+
with await self.pool as connection:
159157
cursor = await connection.cursor()
160158
await cursor.execute(
161159
f"UPDATE farmer SET singleton_tip=%s, singleton_tip_state=%s, is_pool_member=%s WHERE launcher_id=%s",
@@ -164,7 +162,7 @@ async def update_singleton(
164162
await connection.commit()
165163

166164
async def get_pay_to_singleton_phs(self) -> Set[bytes32]:
167-
with (await self.pool) as connection:
165+
with await self.pool as connection:
168166
cursor = await connection.cursor()
169167
await cursor.execute("SELECT p2_singleton_puzzle_hash from farmer")
170168
rows = await cursor.fetchall()
@@ -179,7 +177,7 @@ async def get_farmer_records_for_p2_singleton_phs(self, puzzle_hashes: Set[bytes
179177
if len(puzzle_hashes) == 0:
180178
return []
181179
puzzle_hashes_db = tuple([ph.hex() for ph in list(puzzle_hashes)])
182-
with (await self.pool) as connection:
180+
with await self.pool as connection:
183181
cursor = await connection.cursor()
184182
await cursor.execute(
185183
f'SELECT * from farmer WHERE p2_singleton_puzzle_hash in ({"%s," * (len(puzzle_hashes_db) - 1)}%s) ',
@@ -190,7 +188,7 @@ async def get_farmer_records_for_p2_singleton_phs(self, puzzle_hashes: Set[bytes
190188
return [self._row_to_farmer_record(row) for row in rows]
191189

192190
async def get_farmer_points_and_payout_instructions(self) -> List[Tuple[uint64, bytes]]:
193-
with (await self.pool) as connection:
191+
with await self.pool as connection:
194192
cursor = await connection.cursor()
195193
await cursor.execute(f"SELECT points, payout_instructions FROM farmer")
196194
rows = await cursor.fetchall()
@@ -210,21 +208,21 @@ async def get_farmer_points_and_payout_instructions(self) -> List[Tuple[uint64,
210208
return ret
211209

212210
async def clear_farmer_points(self) -> None:
213-
with (await self.pool) as connection:
211+
with await self.pool as connection:
214212
cursor = await connection.cursor()
215213
await cursor.execute(f"UPDATE farmer SET points=0")
216214
await cursor.close()
217215
await connection.commit()
218216

219217
async def add_partial(self, launcher_id: bytes32, timestamp: uint64, difficulty: uint64):
220-
with (await self.pool) as connection:
218+
with await self.pool as connection:
221219
cursor = await connection.cursor()
222220
await cursor.execute(
223221
"INSERT INTO partial VALUES(%s, %s, %s)",
224222
(launcher_id.hex(), timestamp, difficulty),
225223
)
226224
await connection.commit()
227-
with (await self.pool) as connection:
225+
with await self.pool as connection:
228226
cursor = await connection.cursor()
229227
await cursor.execute(
230228
f"UPDATE farmer SET points=points+%s WHERE launcher_id=%s", (difficulty, launcher_id.hex())
@@ -233,7 +231,7 @@ async def add_partial(self, launcher_id: bytes32, timestamp: uint64, difficulty:
233231
await cursor.close()
234232

235233
async def get_recent_partials(self, launcher_id: bytes32, count: int) -> List[Tuple[uint64, uint64]]:
236-
with (await self.pool) as connection:
234+
with await self.pool as connection:
237235
cursor = await connection.cursor()
238236
await cursor.execute(
239237
"SELECT timestamp, difficulty from partial WHERE launcher_id=%s ORDER BY timestamp DESC LIMIT %s",

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import setuptools
44
from setuptools import setup
55

6+
67
# Utility function to read the README file.
78
# Used for the long_description. It's nice, because now 1) we have a top level
89
# README file and 2) it's easier to type in the README file than to put a raw

tests/test_difficulty.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
class TestDifficulty(unittest.TestCase):
1010
def test_no_things_in_db(self):
11-
1211
time_target = 24 * 3600
1312
current_time = uint64(time.time())
1413
assert get_new_difficulty([], 300, time_target, 10, current_time, 1) == 10

0 commit comments

Comments
 (0)