Skip to content

Docs #21: README no longer says any change to Block or Transaction stops chain.dat loading - #22

Open
tanujb03 wants to merge 1 commit into
techcsispit:mainfrom
tanujb03:docs/21-readme-chain-dat
Open

tanujb03 wants to merge 1 commit into
techcsispit:mainfrom
tanujb03:docs/21-readme-chain-dat

Conversation

@tanujb03

Copy link
Copy Markdown
Contributor

Closes #21

What I changed

One sentence in the README "Saving" section. It said "Change either one and the file stops loading". It now says that adding a field or a method still loads, and that a change Java serialization treats as incompatible (for example changing a field's type, or bumping serialVersionUID in Block) makes the file stop loading and the program start a new chain. No code changes.

How it works

chain.dat is a Java serialized object. Block, Transaction and Blockchain pin serialVersionUID, so compatible edits such as a new field or method deserialize fine, while an incompatible edit throws InvalidClassException, which Storage.load catches before it starts a new chain. I checked the new wording by running the program on a chain.dat saved with the original classes: a new field in Block and a new method in Transaction print Loaded chain.dat., while bumping serialVersionUID in Block or changing a field type prints Couldn't read chain.dat (InvalidClassException), so a new chain was started. mvn test still passes (18 tests).

@techcsispit

Copy link
Copy Markdown
Owner

there is merge conflict please resolve it first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads it

2 participants