Skip to content

Commit 8ba5ed7

Browse files
authored
Merge pull request ethereum#1543 from jannikluhn/beacon-chain-commands
Define beacon chain network commands
2 parents 1410cf5 + c1deede commit 8ba5ed7

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

trinity/protocol/bcc/__init__.py

Whitespace-only changes.

trinity/protocol/bcc/commands.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from rlp import sedes
2+
3+
from p2p.protocol import (
4+
Command,
5+
)
6+
7+
from trinity.rlp.sedes import HashOrNumber
8+
from eth.beacon.types.blocks import BaseBeaconBlock
9+
from eth.beacon.types.attestation_records import AttestationRecord
10+
11+
12+
class Status(Command):
13+
_cmd_id = 0
14+
structure = [
15+
('protocol_version', sedes.big_endian_int),
16+
('network_id', sedes.big_endian_int),
17+
('best_hash', sedes.binary),
18+
]
19+
20+
21+
class GetBeaconBlocks(Command):
22+
_cmd_id = 1
23+
structure = [
24+
('block_slot_or_hash', HashOrNumber()),
25+
('max_blocks', sedes.big_endian_int),
26+
]
27+
28+
29+
class BeaconBlocks(Command):
30+
_cmd_id = 2
31+
structure = sedes.CountableList(BaseBeaconBlock)
32+
33+
34+
class AttestationRecords(Command):
35+
_cmd_id = 3
36+
structure = sedes.CountableList(AttestationRecord)

trinity/protocol/bcc/proto.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import logging
2+
3+
from p2p.protocol import Protocol
4+
5+
from trinity.protocol.bcc.commands import (
6+
Status,
7+
GetBeaconBlocks,
8+
BeaconBlocks,
9+
AttestationRecords,
10+
)
11+
12+
13+
class BCCProtocol(Protocol):
14+
name = "bcc"
15+
version = 0
16+
_commands = [Status, GetBeaconBlocks, BeaconBlocks, AttestationRecords]
17+
cmd_length = 4
18+
logger = logging.getLogger("p2p.bcc.BCCProtocol")

0 commit comments

Comments
 (0)