Skip to content

Python implementation of hobbits(wire protocol for ethereum 2.0 network testing)

License

Notifications You must be signed in to change notification settings

nanspro/Hobbits.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hobbits.py

Build Status

Python implementation of hobbits(wire protocol for ethereum 2.0 network testing)

Perfomance

Prerequisites

  • Python3

Installation

pip install -r requirements.txt

Usage

Encode a message

msg = {'protocol': 'EWP', 'call': 'RPC', 'version': '0.2', 'headers': '', 'body': '{"id":1,"method_id":0x00}'}
encoded = marshall(msg)
print(encoded)

Decode a message

msg = 'EWP 0.2 RPC 0 25\n{"id":1,"method_id":0x00}'
decoded = parse(msg)
print(decoded)

Here is a demo server

SERVER = create()
SERVER.bind(('127.0.0.1', 9000))    
SERVER.listen(10)

while True:
    CONN, ADDR = SERVER.accept()
    print("Received client's request")
    MSG = ''
    while True:
        DATA = CONN.recv(4096)
        print(DATA)
        if not DATA:
            break
        MSG += DATA.decode('utf-8')
    print(MSG)

License

MIT © Pegasys

About

Python implementation of hobbits(wire protocol for ethereum 2.0 network testing)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages