mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
Kryo register FileInputStream and addDefaultSerializer for InputStream (#471)
HashCheckingStream CordaSerializable and FileInputStream Kryo register
This commit is contained in:
committed by
GitHub
parent
d6403ce8cb
commit
f7dd2733f2
@ -65,11 +65,12 @@ class NodeAttachmentService(override var storePath: Path, dataSourceProperties:
|
||||
* inside it, we haven't read the whole file, so we can't check the hash. But when copying it over the network
|
||||
* this will provide an additional safety check against user error.
|
||||
*/
|
||||
private class HashCheckingStream(val expected: SecureHash.SHA256,
|
||||
val expectedSize: Int,
|
||||
input: InputStream,
|
||||
private val counter: CountingInputStream = CountingInputStream(input),
|
||||
private val stream: HashingInputStream = HashingInputStream(Hashing.sha256(), counter)) : FilterInputStream(stream) {
|
||||
@VisibleForTesting @CordaSerializable
|
||||
class HashCheckingStream(val expected: SecureHash.SHA256,
|
||||
val expectedSize: Int,
|
||||
input: InputStream,
|
||||
private val counter: CountingInputStream = CountingInputStream(input),
|
||||
private val stream: HashingInputStream = HashingInputStream(Hashing.sha256(), counter)) : FilterInputStream(stream) {
|
||||
override fun close() {
|
||||
super.close()
|
||||
|
||||
@ -86,7 +87,7 @@ class NodeAttachmentService(override var storePath: Path, dataSourceProperties:
|
||||
private val checkOnLoad: Boolean) : Attachment {
|
||||
override fun open(): InputStream {
|
||||
|
||||
var stream = ByteArrayInputStream(attachment)
|
||||
val stream = ByteArrayInputStream(attachment)
|
||||
|
||||
// This is just an optional safety check. If it slows things down too much it can be disabled.
|
||||
if (id is SecureHash.SHA256 && checkOnLoad)
|
||||
|
Reference in New Issue
Block a user