-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print MempoolInclusionStatus as string when reporting mempool inclusi…
…on status (#11133)
- Loading branch information
Showing
5 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from chia.types.blockchain_format.sized_bytes import bytes32 | ||
from chia.types.mempool_submission_status import MempoolSubmissionStatus | ||
from chia.wallet.transaction_record import TransactionRecord | ||
|
||
|
||
def transaction_submitted_msg(tx: TransactionRecord) -> str: | ||
sent_to = [MempoolSubmissionStatus(s[0], s[1], s[2]).to_json_dict_convenience() for s in tx.sent_to] | ||
return f"Transaction submitted to nodes: {sent_to}" | ||
|
||
|
||
def transaction_status_msg(fingerprint: int, tx_id: bytes32) -> str: | ||
return f"Run 'chia wallet get_transaction -f {fingerprint} -tx 0x{tx_id}' to get status" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from dataclasses import dataclass | ||
from typing import Dict, Optional, Union | ||
|
||
from chia.types.mempool_inclusion_status import MempoolInclusionStatus | ||
from chia.util.ints import uint8 | ||
from chia.util.streamable import Streamable, streamable | ||
|
||
|
||
@streamable | ||
@dataclass(frozen=True) | ||
class MempoolSubmissionStatus(Streamable): | ||
""" | ||
:sent_to: in `TradeRecord` and `TransactionRecord` are a | ||
Tuple of (peer_id: str, status: MempoolInclusionStatus, error: Optional[str]) | ||
MempoolInclusionStatus is represented as a uint8 in those structs so they can be `Streamable` | ||
""" | ||
|
||
peer_id: str | ||
inclusion_status: uint8 # MempoolInclusionStatus | ||
error_msg: Optional[str] | ||
|
||
def to_json_dict_convenience(self) -> Dict[str, Union[str, MempoolInclusionStatus, Optional[str]]]: | ||
formatted = self.to_json_dict() | ||
formatted["inclusion_status"] = MempoolInclusionStatus(self.inclusion_status).name | ||
return formatted | ||
|
||
def __str__(self) -> str: | ||
return f"{self.to_json_dict_convenience()}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters