-
Notifications
You must be signed in to change notification settings - Fork 6
Part six #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Part six #11
Conversation
# Conflicts: # src/blockchain/Block.java # src/blockchain/Blockchain.java # src/blockchain/Main.java # src/blockchain/miners/Miner.java
swsms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great blockchain implementation. A little more, and you can open your own crypto platform. Just implement distributed version of this application :)
| private final String hash; | ||
| private final Long timestamp; | ||
| private final Integer magicNumber; | ||
| private List<T> data = List.of(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good null-avoiding :)
src/blockchain/Blockchain.java
Outdated
| private BiFunction<Integer, String, Optional<T>> systemFeedback; | ||
|
|
||
| public Blockchain(Persister<T> persister, DataFormatter<T> dataFormatter, | ||
| BiFunction<Integer, String, Optional<T>> systemFeedback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The system feedback function is quite large in the definition. Maybe it is better to represent it as your own interface, like:
interface SystemFeedback extends BiFunction<Integer, String, Optional<T>> { ... }
src/blockchain/Blockchain.java
Outdated
|
|
||
| public Stream<T> data() { | ||
| ReadLock readLock = readWritelock.readLock(); | ||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the lock is superfluous here. Since streams are lazy, data from the source will be obtained in a completely different place. Actually, you do not perform the read operation here, just configure your stream to perform this operation somewhere else.
| import java.util.List; | ||
|
|
||
| public class FilePersister<T extends SignedData & Serializable> implements Persister<T> { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not too many empty lines here?
No description provided.