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

Abierto
#21 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@tanujb03 ya está trabajando en esto.

Desde el 10/10/2026.

  • #22 de @tanujb03 — abierto
  • #26 de @YuuGR1337 — abierto

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
25/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
java

Línea de trabajo

The sentence to change is in the README's "Saving" section, which says changing Block or Transaction stops chain.dat from loading. Compare it with the version-comment in Block.java and Transaction.java and with the fallback in Storage.load, which together show that only incompatible serialization changes stop loading. Done means the README says added fields or methods still load and gives one example that does stop loading. A linked pull request (#22) already exists, so check it before starting.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

documentation good first issue

What I did

  1. Fresh checkout of main (0e92205), JDK 17, Maven 3.9.
  2. mvn compile exec:java, then in the menu: 2 (mine a block, name asha), 1 (asha pays ravi 10), 8 (quit). This writes chain.dat.
  3. Followed the README sentence literally and changed Block: added private String note = "added"; under private String hash; in Block.java. Then mvn compile exec:java again.
  4. Repeated from a fresh chain.dat with other changes:
    • added a method public String memo() { return "changed"; } to Transaction
    • changed private static final long serialVersionUID = 2L; to 3L in Block
    • changed the same line to 3L in Transaction
    • changed private int nonce to private long nonce in Block

What I expected
The README, "Saving" section, says:

It is tied to the Block and Transaction classes. Change either one and the file stops loading, and the program starts a new chain instead.

So after any change to Block or Transaction, the program should start a new chain.

What happened instead

Change What the program printed
add a field to Block Loaded chain.dat. (old chain, queued payment and balances intact)
add a method to Transaction Loaded chain.dat.
serialVersionUID 2L to 3L in Block Couldn't read chain.dat (InvalidClassException), so a new chain was started.
serialVersionUID 2L to 3L in Transaction Loaded chain.dat.
nonce int to long in Block Couldn't read chain.dat (InvalidClassException), so a new chain was started.

So the file stops loading only for changes Java serialization treats as incompatible. This looks intended: Block.java and Transaction.java carry the comment // bump version only for incompatible changes, adding a field is safe, and Storage.load falls back to a new chain when it can't read the file. The README sentence is the part that is too broad.

I'd like to fix the README wording only (no code change), so that it says adding a field or method still loads, and gives an example of a change that does make the file stop loading.

Environment
main @ 0e92205, JDK 17.0.12, Maven 3.9.16, Windows 11.

Lenguaje dominante
Java
Estrellas
0
Forks
3
Merge medio
2 d 5 h
PR fusionados (30 d)
15

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de techcsispit/mini-chain

Todos los issues de techcsispit/mini-chain

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.