-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add vertex store size limit; cleanup vertex store events #854
base: develop
Are you sure you want to change the base?
Changes from 3 commits
501a3bf
783d36f
a79c14b
b707db8
1ad56a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,71 +64,9 @@ | |
|
||
package com.radixdlt.consensus.bft; | ||
|
||
import com.radixdlt.consensus.BFTHeader; | ||
import com.radixdlt.consensus.vertexstore.ExecutedVertex; | ||
import com.radixdlt.consensus.vertexstore.VertexStoreState; | ||
import java.util.Objects; | ||
import com.radixdlt.utils.WrappedByteArray; | ||
|
||
/** An update emitted when the BFT has inserted a new vertex */ | ||
public final class BFTInsertUpdate { | ||
private final VertexStoreState vertexStoreState; | ||
private final ExecutedVertex insertedVertex; | ||
private final int siblingsCount; | ||
|
||
private BFTInsertUpdate( | ||
ExecutedVertex insertedVertex, int siblingsCount, VertexStoreState vertexStoreState) { | ||
this.insertedVertex = Objects.requireNonNull(insertedVertex); | ||
this.siblingsCount = siblingsCount; | ||
this.vertexStoreState = Objects.requireNonNull(vertexStoreState); | ||
} | ||
|
||
public static BFTInsertUpdate insertedVertex( | ||
ExecutedVertex insertedVertex, int siblingsCount, VertexStoreState vertexStoreState) { | ||
return new BFTInsertUpdate(insertedVertex, siblingsCount, vertexStoreState); | ||
} | ||
|
||
public VertexStoreState getVertexStoreState() { | ||
return vertexStoreState; | ||
} | ||
|
||
public int getSiblingsCount() { | ||
return siblingsCount; | ||
} | ||
|
||
public int getVertexStoreSize() { | ||
return vertexStoreState.getVertices().size(); | ||
} | ||
|
||
public BFTHeader getHeader() { | ||
return new BFTHeader( | ||
insertedVertex.getRound(), | ||
insertedVertex.getVertexHash(), | ||
insertedVertex.getLedgerHeader()); | ||
} | ||
|
||
public ExecutedVertex getInserted() { | ||
return insertedVertex; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(vertexStoreState, insertedVertex, siblingsCount); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (!(o instanceof BFTInsertUpdate)) { | ||
return false; | ||
} | ||
|
||
BFTInsertUpdate other = (BFTInsertUpdate) o; | ||
return Objects.equals(this.vertexStoreState, other.vertexStoreState) | ||
&& Objects.equals(this.insertedVertex, other.insertedVertex) | ||
&& this.siblingsCount == other.siblingsCount; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s{inserted=%s}", getClass().getSimpleName(), insertedVertex); | ||
} | ||
} | ||
/** An event emitted after a vertex has been inserted into the vertex store. */ | ||
public record BFTInsertUpdate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've lost the nice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise we could end up with a massive log of the serialized vertex state in hex. |
||
ExecutedVertex insertedVertex, WrappedByteArray serializedVertexStoreState) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,42 +65,8 @@ | |
package com.radixdlt.consensus.bft; | ||
|
||
import com.radixdlt.consensus.vertexstore.VertexStoreState; | ||
import java.util.Objects; | ||
import com.radixdlt.utils.WrappedByteArray; | ||
|
||
/** An update emitted when the BFT has been rebuilt */ | ||
public final class BFTRebuildUpdate { | ||
private final VertexStoreState vertexStoreState; | ||
|
||
private BFTRebuildUpdate(VertexStoreState vertexStoreState) { | ||
this.vertexStoreState = vertexStoreState; | ||
} | ||
|
||
public static BFTRebuildUpdate create(VertexStoreState vertexStoreState) { | ||
return new BFTRebuildUpdate(vertexStoreState); | ||
} | ||
|
||
public VertexStoreState getVertexStoreState() { | ||
return vertexStoreState; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format( | ||
"%s{root=%s}", this.getClass().getSimpleName(), vertexStoreState.getRoot()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(vertexStoreState); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (!(o instanceof BFTRebuildUpdate)) { | ||
return false; | ||
} | ||
|
||
BFTRebuildUpdate other = (BFTRebuildUpdate) o; | ||
return Objects.equals(other.vertexStoreState, this.vertexStoreState); | ||
} | ||
} | ||
/** An even emitted when the vertex store has been rebuilt. */ | ||
public record BFTRebuildUpdate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've lost the nice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise we could end up with a massive log of the serialized vertex state in hex. |
||
VertexStoreState vertexStoreState, WrappedByteArray serializedVertexStoreState) {} |
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.
We've lost the nice
toString
here - perhaps we should override it?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.
Otherwise we could end up with a massive log of the serialized vertex state in hex.