Skip to content

Conversation

@oleksiipet
Copy link

No description provided.

@oleksiipet oleksiipet changed the title Part six new Part six Jan 7, 2019
@swsms swsms self-requested a review January 17, 2019 12:52
Copy link

@swsms swsms left a 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();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good null-avoiding :)

private BiFunction<Integer, String, Optional<T>> systemFeedback;

public Blockchain(Persister<T> persister, DataFormatter<T> dataFormatter,
BiFunction<Integer, String, Optional<T>> systemFeedback) {
Copy link

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>> { ... }


public Stream<T> data() {
ReadLock readLock = readWritelock.readLock();
try {
Copy link

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> {

Copy link

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?

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.

3 participants