hiero-ledger / hiero-ledger/hiero-consensus-node
Redefine protocols
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
- currently, an interface called `Protocol` exists in the platform, leave this interface alone.
- a new interface should be created that is called `ProtocolFactory`
- it should have a single method to create a `Protocol`
- `ProtocolFactory` classes should be created for all the current protocols
- Heartbeat
- Sync
- Reconnect
- EmergencyReconnect
- handshake protocols could continue to use the existing interface (with slight modifications)
- for these, we do not need an instance per peer (at least for the time being) since they are stateless, we can use the same instance for all peers
- it might make sense to rename the interface to `HandshakeProtocol`
```
/**
* A factory for creating a protocol.
*
* @param the type of protocol that this factory creates
*/
public interface ProtocolFactory {
/**
* Create a new protocol for the specified peer.
*
* @param peerId the peer to create the protocol for
* @return the new protocol
*/
@NonNull
PROTOCOL build(@NonNull final NodeId peerId);
}
```
```
/**
* Perform a handshake with a peer. All handshakes must be performed successfully before any other protocol can be
* negotiated.
*/
public interface HandshakeProtocol {
/**
* Attempt to perform a handshake with the peer.
*
* @param connection the connection to the peer
* @throws IOException if the handshake fails for any reason
*/
void handshake(final Connection connection) throws IOException;
}
```
Contributor guide
Research direction
The issue does not name files, tests, or entry points. Start by locating the existing Protocol interface and the implementations or construction paths for Heartbeat, Sync, Reconnect, and EmergencyReconnect, then compare how handshake protocols are used. Done means the listed protocols have factories while handshake protocols retain compatible stateless behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100