mirror of
https://github.com/aljazceru/plugins.git
synced 2026-01-10 00:34:23 +01:00
historian: Add a command to read a snapshot and hexdump it to stdout
This commit is contained in:
@@ -6,7 +6,7 @@ from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy import func
|
||||
from datetime import datetime, timedelta
|
||||
import click
|
||||
from pyln.proto.primitives import varint_encode
|
||||
from pyln.proto.primitives import varint_encode, varint_decode
|
||||
import os
|
||||
from sqlalchemy.orm import load_only
|
||||
|
||||
@@ -154,5 +154,20 @@ def full(ctx, destination, db):
|
||||
ctx.invoke(incremental, since=since, destination=destination, db=db)
|
||||
|
||||
|
||||
@snapshot.command()
|
||||
@click.argument('snapshot', type=click.File('rb'))
|
||||
def read(snapshot):
|
||||
while True:
|
||||
l = varint_decode(snapshot)
|
||||
if l is None:
|
||||
break
|
||||
|
||||
msg = snapshot.read(l)
|
||||
if len(msg) != l:
|
||||
raise ValueError("Incomplete read at end of file")
|
||||
|
||||
print(msg.hex())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
||||
Reference in New Issue
Block a user