MCPcopy
hub / github.com/petertodd/python-bitcoinlib / ser_read

Function ser_read

bitcoin/core/serialize.py:58–70  ·  view source on GitHub ↗

Read from a stream safely Raises SerializationError and SerializationTruncationError appropriately. Use this instead of f.read() in your classes stream_(de)serialization() functions.

(f, n)

Source from the content-addressed store, hash-verified

56 self.padding = padding
57
58def ser_read(f, n):
59 """Read from a stream safely
60
61 Raises SerializationError and SerializationTruncationError appropriately.
62 Use this instead of f.read() in your classes stream_(de)serialization()
63 functions.
64 """
65 if n > MAX_SIZE:
66 raise SerializationError('Asked to read 0x%x bytes; MAX_SIZE exceeded' % n)
67 r = f.read(n)
68 if len(r) < n:
69 raise SerializationTruncationError('Asked to read %i bytes, but only got %i' % (n, len(r)))
70 return r
71
72
73class Serializable(object):

Callers 15

stream_deserializeMethod · 0.90
stream_deserializeMethod · 0.90
stream_deserializeMethod · 0.90
stream_deserializeMethod · 0.90
stream_deserializeMethod · 0.85
stream_deserializeMethod · 0.85
msg_deserMethod · 0.85
msg_deserMethod · 0.85
msg_deserMethod · 0.85
msg_deserMethod · 0.85
msg_deserMethod · 0.85
msg_deserMethod · 0.85

Calls 2

SerializationErrorClass · 0.85

Tested by

no test coverage detected