mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-09 08:33:09 +00:00
increase incentive tx size
This commit is contained in:
parent
610d95a6fa
commit
9ac15da7d3
@ -12,6 +12,7 @@ class Node:
|
||||
N_MIXES_IN_PATH = 2
|
||||
REAL_PAYLOAD = b"BLOCK"
|
||||
COVER_PAYLOAD = b"COVER"
|
||||
INCENTIVE_TX_SIZE = 512
|
||||
|
||||
def __init__(self, id: int, env: simpy.Environment, p2p: P2p):
|
||||
self.id = id
|
||||
@ -67,10 +68,12 @@ class Node:
|
||||
else:
|
||||
self.log("Received original message: %s" % msg)
|
||||
|
||||
# TODO: This is a dummy logic
|
||||
@classmethod
|
||||
def create_incentive_tx(cls, mix_public_key: X25519PublicKey) -> Attachment:
|
||||
return Attachment(
|
||||
mix_public_key.public_bytes(encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw))
|
||||
public_key = mix_public_key.public_bytes(encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw)
|
||||
public_key += bytes(cls.INCENTIVE_TX_SIZE - len(public_key))
|
||||
return Attachment(public_key)
|
||||
|
||||
def is_my_incentive_tx(self, tx: Attachment) -> bool:
|
||||
return tx == Node.create_incentive_tx(self.public_key)
|
||||
|
||||
@ -15,7 +15,7 @@ class P2p:
|
||||
|
||||
# TODO: This should accept only bytes, but SphinxPacket is also accepted until we implement the Sphinx serde
|
||||
def broadcast(self, msg: SphinxPacket | bytes):
|
||||
self.log("Broadcasting a msg")
|
||||
self.log("Broadcasting a msg: %d bytes" % len(msg))
|
||||
yield self.env.timeout(1)
|
||||
# TODO: gossipsub or something similar
|
||||
for node in self.nodes:
|
||||
|
||||
@ -18,7 +18,7 @@ class SphinxPacket:
|
||||
def __bytes__(self):
|
||||
return bytes(self.header) + self.payload
|
||||
|
||||
def size(self) -> int:
|
||||
def __len__(self):
|
||||
return len(bytes(self))
|
||||
|
||||
def unwrap(self, private_key: X25519PrivateKey) -> tuple[SphinxPacket, Attachment]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user