Skip to content

Commit

Permalink
Bind protocol update version in pre genesis module (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasGasior1 authored Sep 18, 2023
2 parents 6fed7ad + 9654433 commit bd9641d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@

package com.radixdlt.api.system.genesis;

import static com.radixdlt.protocol.ProtocolVersion.ONLY_PROTOCOL_VERSION;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
Expand All @@ -75,6 +77,9 @@
import com.radixdlt.api.system.health.HealthInfoService;
import com.radixdlt.api.system.routes.HealthHandler;
import com.radixdlt.api.system.routes.VersionHandler;
import com.radixdlt.protocol.Current;
import com.radixdlt.protocol.Newest;
import com.radixdlt.protocol.ProtocolVersion;
import io.undertow.server.HttpHandler;
import java.util.Map;

Expand All @@ -93,6 +98,10 @@ public PreGenesisSystemApiModule(String bindAddress, int port) {

@Override
protected void configure() {
// TODO(when introducing actual protocol updates): design how to manage this
bind(ProtocolVersion.class).annotatedWith(Current.class).toInstance(ONLY_PROTOCOL_VERSION);
bind(ProtocolVersion.class).annotatedWith(Newest.class).toInstance(ONLY_PROTOCOL_VERSION);

bind(HealthInfoService.class).to(PreGenesisHealthInfoService.class).in(Scopes.SINGLETON);

final var binder =
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/com/radixdlt/p2p/P2PModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@

package com.radixdlt.p2p;

import static com.radixdlt.protocol.ProtocolVersion.ONLY_PROTOCOL_VERSION;

import com.google.inject.*;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.multibindings.ProvidesIntoSet;
Expand Down Expand Up @@ -95,9 +97,6 @@

public final class P2PModule extends AbstractModule {

/** The only currently defined protocol version. */
private static final ProtocolVersion ONLY_PROTOCOL_VERSION = new ProtocolVersion("babylon-v1");

private final RuntimeProperties properties;

public P2PModule(RuntimeProperties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@

package com.radixdlt.protocol;

public record ProtocolVersion(String name) {}
public record ProtocolVersion(String name) {
/** The only currently defined protocol version. */
public static final ProtocolVersion ONLY_PROTOCOL_VERSION = new ProtocolVersion("babylon-v1");
}

0 comments on commit bd9641d

Please sign in to comment.