mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-20 08:05:33 +03:00
farming info
This commit is contained in:
parent
4415abb63d
commit
a0a80949af
@ -3,35 +3,42 @@ import { useSelector } from 'react-redux';
|
||||
import { Trans } from '@lingui/macro';
|
||||
import { Table, Card, FormatBytes } from '@chia/core';
|
||||
import { Typography } from '@material-ui/core';
|
||||
import moment from 'moment';
|
||||
import type { Row } from '../core/components/Table/Table';
|
||||
import usePlots from '../../hooks/usePlots';
|
||||
import { RootState } from '../../modules/rootReducer';
|
||||
|
||||
const cols = [
|
||||
{
|
||||
field(row: Row) {
|
||||
return row.signage_point_index;
|
||||
},
|
||||
title: <Trans id="FarmFullNodeConnections.height">Signage Point Index</Trans>,
|
||||
},
|
||||
{
|
||||
field(row: Row) {
|
||||
return row.challenge_hash;
|
||||
},
|
||||
title: <Trans id="FarmFullNodeConnections.date">Challenge Hash</Trans>,
|
||||
title: <Trans id="FarmFullNodeConnections.challenge">Challenge</Trans>,
|
||||
},
|
||||
{
|
||||
field(row: Row) {
|
||||
return row.plot_identifier;
|
||||
return `${row.passed_filter} / ${row.total_plots}`;
|
||||
},
|
||||
title: <Trans id="FarmFullNodeConnections.time">Plot ID</Trans>,
|
||||
title: <Trans id="FarmFullNodeConnections.passed_filter">Plots Passed Filter</Trans>,
|
||||
},
|
||||
{
|
||||
field(row: Row) {
|
||||
return row.proofs;
|
||||
},
|
||||
title: <Trans id="FarmFullNodeConnections.proofs_found">Proofs Found</Trans>,
|
||||
},
|
||||
{
|
||||
field(row: Row) {
|
||||
return moment(row.timestamp * 1000).format('lll');
|
||||
},
|
||||
title: <Trans id="FarmFullNodeConnections.date">Date</Trans>,
|
||||
},
|
||||
];
|
||||
|
||||
export default function FarmLastAttemptedProof() {
|
||||
const { size } = usePlots();
|
||||
|
||||
const lastAttemtedProof = useSelector((state: RootState) => state.farming_state.farmer.last_attempted_proofs ?? []);
|
||||
const lastAttemtedProof = useSelector((state: RootState) => state.farming_state.farmer.last_farming_info ?? []);
|
||||
const reducedLastAttemtedProof = lastAttemtedProof.slice(0, 5);
|
||||
const isEmpty = !reducedLastAttemtedProof.length;
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -883,21 +883,25 @@ msgstr "Total Size of Plots"
|
||||
msgid "FarmFullNodeConnections.actions"
|
||||
msgstr "Actions"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:12
|
||||
msgid "FarmFullNodeConnections.challenge"
|
||||
msgstr "Challenge"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:66
|
||||
msgid "FarmFullNodeConnections.connectionStatus"
|
||||
msgstr "Connection Status:"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:18
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:36
|
||||
msgid "FarmFullNodeConnections.date"
|
||||
msgstr "Challenge Hash"
|
||||
msgstr "Date"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:58
|
||||
msgid "FarmFullNodeConnections.description"
|
||||
msgstr "The full node that your farmer is connected to is below. <0>Learn more</0>"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:12
|
||||
msgid "FarmFullNodeConnections.height"
|
||||
msgstr "Signage Point Index"
|
||||
#~ msgid "FarmFullNodeConnections.height"
|
||||
#~ msgstr "Signage Point Index"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:24
|
||||
msgid "FarmFullNodeConnections.hostName"
|
||||
@ -907,13 +911,25 @@ msgstr "Host Name"
|
||||
msgid "FarmFullNodeConnections.nodeId"
|
||||
msgstr "Node ID"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
msgid "FarmFullNodeConnections.passed_filter"
|
||||
msgstr "Plots Passed Filter"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:30
|
||||
msgid "FarmFullNodeConnections.port"
|
||||
msgstr "Port"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:30
|
||||
msgid "FarmFullNodeConnections.proofs_found"
|
||||
msgstr "Proofs Found"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:18
|
||||
msgid "FarmFullNodeConnections.signage_point"
|
||||
msgstr "Signage Point"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
msgid "FarmFullNodeConnections.time"
|
||||
msgstr "Plot ID"
|
||||
#~ msgid "FarmFullNodeConnections.time"
|
||||
#~ msgstr "Plot ID"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:56
|
||||
msgid "FarmFullNodeConnections.title"
|
||||
@ -923,19 +939,19 @@ msgstr "Your Full Node Connection"
|
||||
msgid "FarmFullNodeConnections.upDown"
|
||||
msgstr "MiB Up/Down"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:38
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:50
|
||||
msgid "FarmLastAttemptedProof.emptyDescription"
|
||||
msgstr "None of your plots have passed the plot filter yet."
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:44
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:56
|
||||
msgid "FarmLastAttemptedProof.emptySubDescription"
|
||||
msgstr "But you are currently farming <0/>"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:32
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:44
|
||||
msgid "FarmLastAttemptedProof.title"
|
||||
msgstr "Last Attempted Proof"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:34
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:46
|
||||
msgid "FarmLastAttemptedProof.tooltip"
|
||||
msgstr "This table shows you the last time your farm attempted to win a block challenge."
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -883,11 +883,15 @@ msgstr "Celková veľkosť polí"
|
||||
msgid "FarmFullNodeConnections.actions"
|
||||
msgstr "Akcie"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:12
|
||||
msgid "FarmFullNodeConnections.challenge"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:66
|
||||
msgid "FarmFullNodeConnections.connectionStatus"
|
||||
msgstr "Stav pripojenia"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:18
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:36
|
||||
msgid "FarmFullNodeConnections.date"
|
||||
msgstr "Dátum"
|
||||
|
||||
@ -896,8 +900,8 @@ msgid "FarmFullNodeConnections.description"
|
||||
msgstr "Kombajn je služba bežiaca na stroji, kde sú skutočne uložené polia. Nižšie si pozrite svoju sieť prepojených kombajnov. Viac informácií"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:12
|
||||
msgid "FarmFullNodeConnections.height"
|
||||
msgstr "Pozícia"
|
||||
#~ msgid "FarmFullNodeConnections.height"
|
||||
#~ msgstr "Pozícia"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:24
|
||||
msgid "FarmFullNodeConnections.hostName"
|
||||
@ -907,13 +911,25 @@ msgstr ""
|
||||
msgid "FarmFullNodeConnections.nodeId"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
msgid "FarmFullNodeConnections.passed_filter"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:30
|
||||
msgid "FarmFullNodeConnections.port"
|
||||
msgstr "Port"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:30
|
||||
msgid "FarmFullNodeConnections.proofs_found"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:18
|
||||
msgid "FarmFullNodeConnections.signage_point"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
msgid "FarmFullNodeConnections.time"
|
||||
msgstr "Čas"
|
||||
#~ msgid "FarmFullNodeConnections.time"
|
||||
#~ msgstr "Čas"
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:56
|
||||
msgid "FarmFullNodeConnections.title"
|
||||
@ -923,19 +939,19 @@ msgstr "Vaše pripojenie k sieti"
|
||||
msgid "FarmFullNodeConnections.upDown"
|
||||
msgstr "Odoslané/Stiahnuté"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:38
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:50
|
||||
msgid "FarmLastAttemptedProof.emptyDescription"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:44
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:56
|
||||
msgid "FarmLastAttemptedProof.emptySubDescription"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:32
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:44
|
||||
msgid "FarmLastAttemptedProof.title"
|
||||
msgstr "Posledný pokus o dôkaz"
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:34
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:46
|
||||
msgid "FarmLastAttemptedProof.tooltip"
|
||||
msgstr ""
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -883,11 +883,15 @@ msgstr ""
|
||||
msgid "FarmFullNodeConnections.actions"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:12
|
||||
msgid "FarmFullNodeConnections.challenge"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:66
|
||||
msgid "FarmFullNodeConnections.connectionStatus"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:18
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:36
|
||||
msgid "FarmFullNodeConnections.date"
|
||||
msgstr ""
|
||||
|
||||
@ -896,8 +900,8 @@ msgid "FarmFullNodeConnections.description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:12
|
||||
msgid "FarmFullNodeConnections.height"
|
||||
msgstr ""
|
||||
#~ msgid "FarmFullNodeConnections.height"
|
||||
#~ msgstr ""
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:24
|
||||
msgid "FarmFullNodeConnections.hostName"
|
||||
@ -907,14 +911,26 @@ msgstr ""
|
||||
msgid "FarmFullNodeConnections.nodeId"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
msgid "FarmFullNodeConnections.passed_filter"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:30
|
||||
msgid "FarmFullNodeConnections.port"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
msgid "FarmFullNodeConnections.time"
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:30
|
||||
msgid "FarmFullNodeConnections.proofs_found"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:18
|
||||
msgid "FarmFullNodeConnections.signage_point"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:24
|
||||
#~ msgid "FarmFullNodeConnections.time"
|
||||
#~ msgstr ""
|
||||
|
||||
#: src/components/farm/FarmFullNodeConnections.tsx:56
|
||||
msgid "FarmFullNodeConnections.title"
|
||||
msgstr ""
|
||||
@ -923,19 +939,19 @@ msgstr ""
|
||||
msgid "FarmFullNodeConnections.upDown"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:38
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:50
|
||||
msgid "FarmLastAttemptedProof.emptyDescription"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:44
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:56
|
||||
msgid "FarmLastAttemptedProof.emptySubDescription"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:32
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:44
|
||||
msgid "FarmLastAttemptedProof.title"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:34
|
||||
#: src/components/farm/FarmLastAttemptedProof.tsx:46
|
||||
msgid "FarmLastAttemptedProof.tooltip"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { service_farmer, service_harvester } from '../util/service_names';
|
||||
import type Plot from '../types/Plot';
|
||||
import type Challenge from '../types/Challenge';
|
||||
import type FarmingInfo from '../types/FarmingInfo';
|
||||
import type SignagePoint from '../types/SignagePoint';
|
||||
import type ProofsOfSpace from '../types/ProofsOfSpace';
|
||||
|
||||
@ -12,7 +12,7 @@ type SignagePointAndProofsOfSpace = {
|
||||
type FarmingState = {
|
||||
farmer: {
|
||||
signage_points: SignagePointAndProofsOfSpace[];
|
||||
last_attempted_proofs: Challenge[];
|
||||
last_farming_info: FarmingInfo[];
|
||||
connections: {
|
||||
bytes_read: number;
|
||||
bytes_written: number;
|
||||
@ -39,7 +39,7 @@ type FarmingState = {
|
||||
const initialState: FarmingState = {
|
||||
farmer: {
|
||||
signage_points: [],
|
||||
last_attempted_proofs: [],
|
||||
last_farming_info: [],
|
||||
connections: [],
|
||||
open_connection_error: '',
|
||||
},
|
||||
@ -65,17 +65,16 @@ export default function farmingReducer(
|
||||
const { command } = message;
|
||||
|
||||
// Farmer API
|
||||
if (command === 'proof') {
|
||||
const last_attempted_proofs = [
|
||||
data.proof,
|
||||
...state.farmer.last_attempted_proofs,
|
||||
if (command === 'new_farming_info') {
|
||||
const last_farming_info = [
|
||||
data.farming_info,
|
||||
...state.farmer.last_farming_info,
|
||||
];
|
||||
|
||||
return {
|
||||
...state,
|
||||
farmer: {
|
||||
...state.farmer,
|
||||
last_attempted_proofs,
|
||||
last_farming_info,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
10
electron-react/src/types/FarmingInfo.ts
Normal file
10
electron-react/src/types/FarmingInfo.ts
Normal file
@ -0,0 +1,10 @@
|
||||
type FarmingInfo = {
|
||||
challenge_hash: string;
|
||||
signage_point: string;
|
||||
timestamp: number;
|
||||
passed_filter: number;
|
||||
proofs: number;
|
||||
total_plots: number;
|
||||
};
|
||||
|
||||
export default FarmingInfo;
|
@ -264,3 +264,19 @@ class FarmerAPI:
|
||||
|
||||
msg = Message("request_signatures", request)
|
||||
await self.farmer.server.send_to_specific([msg], node_id)
|
||||
|
||||
@api_request
|
||||
async def farming_info(self, request: farmer_protocol.FarmingInfo):
|
||||
self.farmer.state_changed(
|
||||
"new_farming_info",
|
||||
{
|
||||
"farming_info": {
|
||||
"challenge_hash": request.challenge_hash,
|
||||
"signage_point": request.sp_hash,
|
||||
"passed_filter": request.passed,
|
||||
"proofs": request.proofs,
|
||||
"total_plots": request.total_plots,
|
||||
"timestamp": request.timestamp,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -14,12 +14,13 @@ from src.consensus.pot_iterations import (
|
||||
from src.harvester.harvester import Harvester
|
||||
from src.plotting.plot_tools import PlotInfo
|
||||
from src.protocols import harvester_protocol
|
||||
from src.protocols.farmer_protocol import FarmingInfo
|
||||
from src.server.outbound_message import Message
|
||||
from src.server.ws_connection import WSChiaConnection
|
||||
from src.types.proof_of_space import ProofOfSpace
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.api_decorators import api_request, peer_required
|
||||
from src.util.ints import uint8, uint64
|
||||
from src.util.ints import uint8, uint64, uint32
|
||||
|
||||
|
||||
class HarvesterAPI:
|
||||
@ -164,16 +165,20 @@ class HarvesterAPI:
|
||||
return all_responses
|
||||
|
||||
awaitables = []
|
||||
passed = 0
|
||||
total = 0
|
||||
for try_plot_filename, try_plot_info in self.harvester.provers.items():
|
||||
if try_plot_filename.exists():
|
||||
# Passes the plot filter (does not check sp filter yet though, since we have not reached sp)
|
||||
# This is being executed at the beginning of the slot
|
||||
total += 1
|
||||
if ProofOfSpace.passes_plot_filter(
|
||||
self.harvester.constants,
|
||||
try_plot_info.prover.get_id(),
|
||||
new_challenge.challenge_hash,
|
||||
new_challenge.sp_hash,
|
||||
):
|
||||
passed += 1
|
||||
awaitables.append(lookup_challenge(try_plot_filename, try_plot_info))
|
||||
|
||||
# Concurrently executes all lookups on disk, to take advantage of multiple disk parallelism
|
||||
@ -183,6 +188,18 @@ class HarvesterAPI:
|
||||
total_proofs_found += 1
|
||||
msg = Message("new_proof_of_space", response)
|
||||
await peer.send_message(msg)
|
||||
|
||||
now = uint64(int(time.time()))
|
||||
farming_info = FarmingInfo(
|
||||
new_challenge.challenge_hash,
|
||||
new_challenge.sp_hash,
|
||||
now,
|
||||
uint32(passed),
|
||||
uint32(total_proofs_found),
|
||||
uint32(total),
|
||||
)
|
||||
pass_msg = Message("farming_info", farming_info)
|
||||
await peer.send_message(pass_msg)
|
||||
self.harvester.log.info(
|
||||
f"{len(awaitables)} plots were eligible for farming {new_challenge.challenge_hash.hex()[:10]}..."
|
||||
f" Found {total_proofs_found} proofs. Time: {time.time() - start:.5f} s. "
|
||||
|
@ -6,7 +6,7 @@ from src.types.proof_of_space import ProofOfSpace
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.types.pool_target import PoolTarget
|
||||
from src.util.cbor_message import cbor_message
|
||||
from src.util.ints import uint64, uint8
|
||||
from src.util.ints import uint64, uint8, uint32
|
||||
|
||||
"""
|
||||
Protocol between farmer and full node.
|
||||
@ -47,6 +47,17 @@ class RequestSignedValues:
|
||||
foliage_block_hash: bytes32
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class FarmingInfo:
|
||||
challenge_hash: bytes32
|
||||
sp_hash: bytes32
|
||||
timestamp: uint64
|
||||
passed: uint32
|
||||
proofs: uint32
|
||||
total_plots: uint32
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class SignedValues:
|
||||
|
@ -1,7 +1,6 @@
|
||||
from typing import Callable, Dict, List
|
||||
|
||||
from src.farmer.farmer import Farmer
|
||||
from src.protocols.farmer_protocol import DeclareProofOfSpace
|
||||
from src.util.byte_types import hexstr_to_bytes
|
||||
from src.util.ws_message import create_payload
|
||||
|
||||
@ -30,20 +29,11 @@ class FarmerRpcApi:
|
||||
string=False,
|
||||
)
|
||||
]
|
||||
elif change == "proof":
|
||||
proof: DeclareProofOfSpace = change_data["proof"]
|
||||
data = {
|
||||
"proof": {
|
||||
"challenge_hash": proof.challenge_hash,
|
||||
"reward_chain_sp": proof.reward_chain_sp,
|
||||
"plot_identifier": proof.proof_of_space.plot_public_key,
|
||||
"signage_point_index": proof.signage_point_index,
|
||||
}
|
||||
}
|
||||
elif change == "new_farming_info":
|
||||
return [
|
||||
create_payload(
|
||||
"proof",
|
||||
data,
|
||||
"new_farming_info",
|
||||
change_data,
|
||||
self.service_name,
|
||||
"wallet_ui",
|
||||
string=False,
|
||||
|
Loading…
Reference in New Issue
Block a user