Skip to content

Commit

Permalink
Rust parse serialized (Chia-Network#3444)
Browse files Browse the repository at this point in the history
* use rust implementation for finding length of a serialized clvm program

* bump clvm_rs version
  • Loading branch information
arvidn authored May 3, 2021
1 parent 74f7d97 commit ca4b252
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions chia/types/blockchain_format/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from clvm.casts import int_from_bytes
from clvm.EvalError import EvalError
from clvm.operators import OP_REWRITE, OPERATOR_LOOKUP
from clvm.serialize import sexp_buffer_from_stream, sexp_from_stream, sexp_to_stream
from clvm_rs import STRICT_MODE, deserialize_and_run_program
from clvm.serialize import sexp_from_stream, sexp_to_stream
from clvm_rs import STRICT_MODE, deserialize_and_run_program, serialized_length
from clvm_tools.curry import curry, uncurry

from chia.types.blockchain_format.sized_bytes import bytes32
Expand Down Expand Up @@ -148,8 +148,8 @@ class SerializedProgram:

@classmethod
def parse(cls, f) -> "SerializedProgram":
tmp = sexp_buffer_from_stream(f)
return SerializedProgram.from_bytes(tmp)
length = serialized_length(f.getvalue()[f.tell() :])
return SerializedProgram.from_bytes(f.read(length))

def stream(self, f):
f.write(self._buf)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"chiabip158==1.0", # bip158-style wallet filters
"chiapos==1.0.1", # proof of space
"clvm==0.9.6",
"clvm_rs==0.1.6",
"clvm_rs==0.1.7",
"clvm_tools==0.4.3",
"aiohttp==3.7.4", # HTTP server for full node rpc
"aiosqlite==0.17.0", # asyncio wrapper for sqlite, to store blocks
Expand Down

0 comments on commit ca4b252

Please sign in to comment.