astreum 0.1.17__tar.gz → 0.1.19__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of astreum might be problematic. Click here for more details.
- {astreum-0.1.17/src/astreum.egg-info → astreum-0.1.19}/PKG-INFO +1 -1
- {astreum-0.1.17 → astreum-0.1.19}/pyproject.toml +1 -1
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/__init__.py +5 -38
- astreum-0.1.19/src/astreum/node/validation/_block/__init__.py +0 -0
- astreum-0.1.19/src/astreum/node/validation/block.py +21 -0
- astreum-0.1.19/src/astreum/utils/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19/src/astreum.egg-info}/PKG-INFO +1 -1
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum.egg-info/SOURCES.txt +0 -1
- astreum-0.1.17/src/astreum/node/validation/__init__.py +0 -84
- astreum-0.1.17/src/astreum/node/validation/_block/__init__.py +0 -12
- astreum-0.1.17/src/astreum/node/validation/block.py +0 -30
- astreum-0.1.17/src/astreum/node/validation/state.py +0 -230
- {astreum-0.1.17 → astreum-0.1.19}/LICENSE +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/README.md +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/setup.cfg +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/expression.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/parser.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/definition.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/all.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/any.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/fold.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/get.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/insert.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/map.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/position.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/list/remove.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/number/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/special/number/addition.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/storage.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/tokenizer.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/lispeum/utils.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/machine/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/machine/environment.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/machine/error.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/crypto/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/crypto/ed25519.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/crypto/x25519.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/relay/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/relay/bucket.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/relay/envelope.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/relay/message.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/relay/peer.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/relay/route.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/storage/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/storage/merkle.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/storage/patricia.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/storage/storage.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/storage/utils.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/utils.py +0 -0
- {astreum-0.1.17/src/astreum/utils → astreum-0.1.19/src/astreum/node/validation}/__init__.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/_block/create.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/_block/model.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/_block/validate.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/account.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/constants.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/stake.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/transaction.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/node/validation/vdf.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum/utils/bytes_format.py +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum.egg-info/dependency_links.txt +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum.egg-info/requires.txt +0 -0
- {astreum-0.1.17 → astreum-0.1.19}/src/astreum.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
4
4
|
Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
|
|
5
5
|
Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/astreum/lib
|
|
@@ -1,47 +1,14 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import time
|
|
3
2
|
import threading
|
|
4
|
-
import
|
|
5
|
-
from typing import Tuple, Optional, List, Dict
|
|
6
|
-
import json
|
|
3
|
+
from typing import List
|
|
7
4
|
from cryptography.hazmat.primitives.asymmetric import ed25519
|
|
8
5
|
from cryptography.hazmat.primitives import serialization
|
|
9
6
|
|
|
10
7
|
from .relay import Relay, Topic
|
|
11
|
-
from
|
|
12
|
-
from .
|
|
13
|
-
from .
|
|
14
|
-
from .
|
|
15
|
-
from astreum.lispeum.storage import store_expr, get_expr_from_storage
|
|
16
|
-
|
|
17
|
-
# Import our validation components using the new functional approach
|
|
18
|
-
from .validation import (
|
|
19
|
-
validate_block,
|
|
20
|
-
create_block,
|
|
21
|
-
create_genesis_block,
|
|
22
|
-
compute_vdf,
|
|
23
|
-
verify_vdf,
|
|
24
|
-
select_validator,
|
|
25
|
-
select_validator_for_slot,
|
|
26
|
-
Account,
|
|
27
|
-
get_validator_stake,
|
|
28
|
-
is_validator,
|
|
29
|
-
VALIDATION_ADDRESS,
|
|
30
|
-
BURN_ADDRESS,
|
|
31
|
-
MIN_STAKE_AMOUNT,
|
|
32
|
-
SLOT_DURATION,
|
|
33
|
-
VDF_DIFFICULTY
|
|
34
|
-
)
|
|
35
|
-
from .validation.state import (
|
|
36
|
-
add_block_to_state,
|
|
37
|
-
validate_and_apply_block,
|
|
38
|
-
create_account_state,
|
|
39
|
-
get_validator_for_slot,
|
|
40
|
-
select_best_chain,
|
|
41
|
-
compare_chains,
|
|
42
|
-
get_validator_set
|
|
43
|
-
)
|
|
44
|
-
from .validation.adapter import BlockAdapter, TransactionAdapter, AccountAdapter
|
|
8
|
+
from ..machine import AstreumMachine
|
|
9
|
+
from .utils import hash_data
|
|
10
|
+
from .validation.block import Block
|
|
11
|
+
from .storage import Storage
|
|
45
12
|
|
|
46
13
|
class Node:
|
|
47
14
|
def __init__(self, config: dict):
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class Block:
|
|
2
|
+
|
|
3
|
+
def __init__(self):
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
@classmethod
|
|
7
|
+
def from_bytes(cls) -> 'Block':
|
|
8
|
+
"""
|
|
9
|
+
Deserialize a block from its byte representation.
|
|
10
|
+
"""
|
|
11
|
+
return cls()
|
|
12
|
+
|
|
13
|
+
def to_bytes(self) -> bytes:
|
|
14
|
+
"""
|
|
15
|
+
Serialize the block into bytes.
|
|
16
|
+
"""
|
|
17
|
+
return b""
|
|
18
|
+
|
|
19
|
+
class Chain:
|
|
20
|
+
def __init__(self, latest_block: Block):
|
|
21
|
+
self.latest_block = latest_block
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
4
4
|
Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
|
|
5
5
|
Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/astreum/lib
|
|
@@ -50,7 +50,6 @@ src/astreum/node/validation/account.py
|
|
|
50
50
|
src/astreum/node/validation/block.py
|
|
51
51
|
src/astreum/node/validation/constants.py
|
|
52
52
|
src/astreum/node/validation/stake.py
|
|
53
|
-
src/astreum/node/validation/state.py
|
|
54
53
|
src/astreum/node/validation/transaction.py
|
|
55
54
|
src/astreum/node/validation/vdf.py
|
|
56
55
|
src/astreum/node/validation/_block/__init__.py
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Validation module for the Astreum blockchain.
|
|
3
|
-
|
|
4
|
-
This module provides functions for validating blocks and transactions,
|
|
5
|
-
computing and verifying VDFs, and selecting validators.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
# Export validation functions
|
|
9
|
-
from .block import (
|
|
10
|
-
validate_block,
|
|
11
|
-
create_block,
|
|
12
|
-
create_genesis_block,
|
|
13
|
-
select_validator,
|
|
14
|
-
select_validator_for_slot
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
# Export VDF functions
|
|
18
|
-
from .vdf import (
|
|
19
|
-
compute_vdf,
|
|
20
|
-
verify_vdf,
|
|
21
|
-
validate_block_vdf
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
# Export account functions
|
|
25
|
-
from .account import (
|
|
26
|
-
Account,
|
|
27
|
-
get_validator_stake,
|
|
28
|
-
is_validator
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
# Export constants
|
|
32
|
-
from .constants import (
|
|
33
|
-
VALIDATION_ADDRESS,
|
|
34
|
-
BURN_ADDRESS,
|
|
35
|
-
MIN_STAKE_AMOUNT,
|
|
36
|
-
SLOT_DURATION,
|
|
37
|
-
VDF_DIFFICULTY
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
# Export blockchain state functions
|
|
41
|
-
from .state import (
|
|
42
|
-
add_block_to_state,
|
|
43
|
-
validate_and_apply_block,
|
|
44
|
-
create_account_state,
|
|
45
|
-
get_validator_for_slot,
|
|
46
|
-
select_best_chain,
|
|
47
|
-
compare_chains,
|
|
48
|
-
get_validator_set
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
__all__ = [
|
|
52
|
-
# Block validation
|
|
53
|
-
'validate_block',
|
|
54
|
-
'create_block',
|
|
55
|
-
'create_genesis_block',
|
|
56
|
-
'select_validator',
|
|
57
|
-
'select_validator_for_slot',
|
|
58
|
-
|
|
59
|
-
# VDF functions
|
|
60
|
-
'compute_vdf',
|
|
61
|
-
'verify_vdf',
|
|
62
|
-
'validate_block_vdf',
|
|
63
|
-
|
|
64
|
-
# Account functions
|
|
65
|
-
'Account',
|
|
66
|
-
'get_validator_stake',
|
|
67
|
-
'is_validator',
|
|
68
|
-
|
|
69
|
-
# Constants
|
|
70
|
-
'VALIDATION_ADDRESS',
|
|
71
|
-
'BURN_ADDRESS',
|
|
72
|
-
'MIN_STAKE_AMOUNT',
|
|
73
|
-
'SLOT_DURATION',
|
|
74
|
-
'VDF_DIFFICULTY',
|
|
75
|
-
|
|
76
|
-
# Blockchain state
|
|
77
|
-
'add_block_to_state',
|
|
78
|
-
'validate_and_apply_block',
|
|
79
|
-
'create_account_state',
|
|
80
|
-
'get_validator_for_slot',
|
|
81
|
-
'select_best_chain',
|
|
82
|
-
'compare_chains',
|
|
83
|
-
'get_validator_set'
|
|
84
|
-
]
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
class Block:
|
|
2
|
-
@classmethod
|
|
3
|
-
def from_bytes(cls, validator) -> 'Block':
|
|
4
|
-
"""
|
|
5
|
-
Deserialize an Account from its byte representation.
|
|
6
|
-
|
|
7
|
-
Expected format: [balance, code, counter, data]
|
|
8
|
-
|
|
9
|
-
The public_key (and optional secret_key) must be provided separately.
|
|
10
|
-
"""
|
|
11
|
-
decoded = bytes_format.decode(data)
|
|
12
|
-
balance, code, counter, account_data = decoded
|
|
13
|
-
return cls(public_key, balance, code, counter, account_data, secret_key=secret_key)
|
|
14
|
-
|
|
15
|
-
def to_bytes(self) -> bytes:
|
|
16
|
-
"""
|
|
17
|
-
Serialize the Account into bytes.
|
|
18
|
-
|
|
19
|
-
Format: [balance, code, counter, data]
|
|
20
|
-
"""
|
|
21
|
-
return bytes_format.encode([
|
|
22
|
-
self.balance,
|
|
23
|
-
self.code,
|
|
24
|
-
self.counter,
|
|
25
|
-
self.data
|
|
26
|
-
])
|
|
27
|
-
|
|
28
|
-
class Chain:
|
|
29
|
-
def __init__(self, latest_block: Block):
|
|
30
|
-
self.latest_block = latest_block
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Blockchain state management.
|
|
3
|
-
|
|
4
|
-
This module manages the blockchain state, including accounts, blocks, and
|
|
5
|
-
transactions.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import time
|
|
9
|
-
from typing import Dict, List, Optional, Set, Any
|
|
10
|
-
from dataclasses import dataclass, field
|
|
11
|
-
from ..utils import hash_data
|
|
12
|
-
from ..models import Block, Transaction, Account as ModelAccount
|
|
13
|
-
from .account import Account
|
|
14
|
-
from .constants import VALIDATION_ADDRESS, BURN_ADDRESS, MIN_STAKE_AMOUNT
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class BlockchainState:
|
|
18
|
-
"""
|
|
19
|
-
Manages the state of the blockchain.
|
|
20
|
-
|
|
21
|
-
This class tracks the current state of accounts, blocks, and transactions,
|
|
22
|
-
and provides methods to update the state with new blocks and transactions.
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
def __init__(self, config: Optional[dict] = None):
|
|
26
|
-
"""
|
|
27
|
-
Initialize blockchain state.
|
|
28
|
-
|
|
29
|
-
Args:
|
|
30
|
-
config: Optional configuration
|
|
31
|
-
"""
|
|
32
|
-
self.config = config or {}
|
|
33
|
-
|
|
34
|
-
# Dictionaries to track blockchain state
|
|
35
|
-
self.accounts = {} # address -> Account
|
|
36
|
-
self.blocks = {} # hash -> Block
|
|
37
|
-
self.transactions = {} # hash -> Transaction
|
|
38
|
-
|
|
39
|
-
# Track the latest block
|
|
40
|
-
self.latest_block = None
|
|
41
|
-
|
|
42
|
-
# Pending transactions
|
|
43
|
-
self.pending_transactions = set() # Set of transaction hashes
|
|
44
|
-
|
|
45
|
-
# State of validators and stakes
|
|
46
|
-
self.validators = {} # address -> stake amount
|
|
47
|
-
|
|
48
|
-
# Initialize the genesis block if not provided
|
|
49
|
-
if not self.latest_block:
|
|
50
|
-
self._initialize_genesis()
|
|
51
|
-
|
|
52
|
-
def _initialize_genesis(self):
|
|
53
|
-
"""Initialize the genesis block and state."""
|
|
54
|
-
# In a full implementation, this would initialize the genesis
|
|
55
|
-
# block and state from configuration
|
|
56
|
-
print("Initializing genesis block and state")
|
|
57
|
-
|
|
58
|
-
def add_block(self, block: Block) -> bool:
|
|
59
|
-
"""
|
|
60
|
-
Add a block to the blockchain state.
|
|
61
|
-
|
|
62
|
-
Args:
|
|
63
|
-
block: Block to add
|
|
64
|
-
|
|
65
|
-
Returns:
|
|
66
|
-
True if block was added successfully, False otherwise
|
|
67
|
-
"""
|
|
68
|
-
# Convert block to validation format directly
|
|
69
|
-
validation_block = {
|
|
70
|
-
'number': block.number,
|
|
71
|
-
'timestamp': block.time,
|
|
72
|
-
'producer': block.validator.public_key if block.validator else b'',
|
|
73
|
-
'previous': block.previous.get_hash() if block.previous else b'',
|
|
74
|
-
'transactions': self._extract_transactions(block),
|
|
75
|
-
'vdf_proof': block.signature[:8], # Use part of signature as VDF proof for demo
|
|
76
|
-
'signature': block.signature
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
# Check for duplicate (already processed) blocks
|
|
80
|
-
block_hash = block.get_hash()
|
|
81
|
-
if block_hash in self.blocks:
|
|
82
|
-
print(f"Block {block_hash.hex()} already in blockchain")
|
|
83
|
-
return True
|
|
84
|
-
|
|
85
|
-
# Convert block's accounts to validation accounts
|
|
86
|
-
account_dict = {}
|
|
87
|
-
# Here we would deserialize the accounts data from the block
|
|
88
|
-
# In a real implementation, this would reconstruct accounts from serialized data
|
|
89
|
-
|
|
90
|
-
# For now, we'll just log that we would process the block
|
|
91
|
-
print(f"Processing block at height {block.number}")
|
|
92
|
-
|
|
93
|
-
# Add the block to our state
|
|
94
|
-
self.blocks[block_hash] = block
|
|
95
|
-
|
|
96
|
-
# Update latest block if this is a new latest block
|
|
97
|
-
if not self.latest_block or block.number > self.latest_block.number:
|
|
98
|
-
self.latest_block = block
|
|
99
|
-
|
|
100
|
-
# Process transactions in the block
|
|
101
|
-
# This would update account states, apply transaction effects, etc.
|
|
102
|
-
|
|
103
|
-
return True
|
|
104
|
-
|
|
105
|
-
def _extract_transactions(self, block: Block) -> List[dict]:
|
|
106
|
-
"""
|
|
107
|
-
Extract transactions from a block.
|
|
108
|
-
|
|
109
|
-
Args:
|
|
110
|
-
block: The model Block instance
|
|
111
|
-
|
|
112
|
-
Returns:
|
|
113
|
-
List of transactions in validation format
|
|
114
|
-
"""
|
|
115
|
-
transactions = []
|
|
116
|
-
# Parse transaction data from the block
|
|
117
|
-
# In a real implementation, this would deserialize the transactions field
|
|
118
|
-
# For now, we'll return an empty list as a placeholder
|
|
119
|
-
return transactions
|
|
120
|
-
|
|
121
|
-
def add_transaction(self, transaction: Transaction) -> bool:
|
|
122
|
-
"""
|
|
123
|
-
Add a transaction to the pending set.
|
|
124
|
-
|
|
125
|
-
Args:
|
|
126
|
-
transaction: Transaction to add
|
|
127
|
-
|
|
128
|
-
Returns:
|
|
129
|
-
True if transaction was added successfully, False otherwise
|
|
130
|
-
"""
|
|
131
|
-
# Convert transaction to validation format directly
|
|
132
|
-
validation_tx = {
|
|
133
|
-
'sender': transaction.sender.public_key if transaction.sender else b'',
|
|
134
|
-
'recipient': transaction.receipient.public_key if transaction.receipient else b'',
|
|
135
|
-
'amount': transaction.amount,
|
|
136
|
-
'counter': transaction.counter,
|
|
137
|
-
'data': transaction.data,
|
|
138
|
-
'signature': transaction.signature
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
# Generate a transaction hash
|
|
142
|
-
tx_hash = hash_data(str(validation_tx).encode())
|
|
143
|
-
|
|
144
|
-
# Check for duplicate transactions
|
|
145
|
-
if tx_hash in self.transactions or tx_hash in self.pending_transactions:
|
|
146
|
-
print(f"Transaction {tx_hash.hex()} already processed or pending")
|
|
147
|
-
return False
|
|
148
|
-
|
|
149
|
-
# Validate the transaction
|
|
150
|
-
# In a real implementation, this would check signature, sender balance, etc.
|
|
151
|
-
|
|
152
|
-
# Add to pending transactions
|
|
153
|
-
self.pending_transactions.add(tx_hash)
|
|
154
|
-
|
|
155
|
-
return True
|
|
156
|
-
|
|
157
|
-
def is_staking_transaction(self, tx: Transaction) -> bool:
|
|
158
|
-
"""
|
|
159
|
-
Check if a transaction is a staking transaction.
|
|
160
|
-
|
|
161
|
-
Args:
|
|
162
|
-
tx: The model Transaction instance
|
|
163
|
-
|
|
164
|
-
Returns:
|
|
165
|
-
True if this is a staking transaction, False otherwise
|
|
166
|
-
"""
|
|
167
|
-
# A transaction is a staking transaction if it's sending to the validation address
|
|
168
|
-
if tx.receipient and hasattr(tx.receipient, 'public_key'):
|
|
169
|
-
return tx.receipient.public_key == VALIDATION_ADDRESS
|
|
170
|
-
return False
|
|
171
|
-
|
|
172
|
-
def get_account(self, address: bytes) -> Optional[Account]:
|
|
173
|
-
"""
|
|
174
|
-
Get an account by address.
|
|
175
|
-
|
|
176
|
-
Args:
|
|
177
|
-
address: Account address
|
|
178
|
-
|
|
179
|
-
Returns:
|
|
180
|
-
Account if found, None otherwise
|
|
181
|
-
"""
|
|
182
|
-
return self.accounts.get(address)
|
|
183
|
-
|
|
184
|
-
def get_validator_stake(self, address: bytes) -> int:
|
|
185
|
-
"""
|
|
186
|
-
Get the stake of a validator.
|
|
187
|
-
|
|
188
|
-
Args:
|
|
189
|
-
address: Validator address
|
|
190
|
-
|
|
191
|
-
Returns:
|
|
192
|
-
Stake amount (0 if not a validator)
|
|
193
|
-
"""
|
|
194
|
-
return self.validators.get(address, 0)
|
|
195
|
-
|
|
196
|
-
def is_validator(self, address: bytes) -> bool:
|
|
197
|
-
"""
|
|
198
|
-
Check if an address is a validator.
|
|
199
|
-
|
|
200
|
-
Args:
|
|
201
|
-
address: Address to check
|
|
202
|
-
|
|
203
|
-
Returns:
|
|
204
|
-
True if address is a validator, False otherwise
|
|
205
|
-
"""
|
|
206
|
-
return self.get_validator_stake(address) >= MIN_STAKE_AMOUNT
|
|
207
|
-
|
|
208
|
-
def get_pending_transactions(self) -> List[Transaction]:
|
|
209
|
-
"""
|
|
210
|
-
Get all pending transactions.
|
|
211
|
-
|
|
212
|
-
Returns:
|
|
213
|
-
List of pending transactions
|
|
214
|
-
"""
|
|
215
|
-
# In a real implementation, this would return the actual transaction objects
|
|
216
|
-
# For now, we'll just return an empty list
|
|
217
|
-
return []
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def create_blockchain(config: Optional[dict] = None) -> BlockchainState:
|
|
221
|
-
"""
|
|
222
|
-
Create a new blockchain state.
|
|
223
|
-
|
|
224
|
-
Args:
|
|
225
|
-
config: Optional configuration
|
|
226
|
-
|
|
227
|
-
Returns:
|
|
228
|
-
New BlockchainState instance
|
|
229
|
-
"""
|
|
230
|
-
return BlockchainState(config)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|