62
62
import com .swirlds .platform .builder .PlatformBuildingBlocks ;
63
63
import com .swirlds .platform .builder .PlatformComponentBuilder ;
64
64
import com .swirlds .platform .components .AppNotifier ;
65
- import com .swirlds .platform .components .ConsensusEngine ;
66
65
import com .swirlds .platform .components .DefaultAppNotifier ;
67
- import com .swirlds .platform .components .DefaultConsensusEngine ;
68
66
import com .swirlds .platform .components .DefaultEventWindowManager ;
69
67
import com .swirlds .platform .components .DefaultSavedStateController ;
70
68
import com .swirlds .platform .components .EventWindowManager ;
71
69
import com .swirlds .platform .components .SavedStateController ;
72
70
import com .swirlds .platform .components .appcomm .DefaultLatestCompleteStateNotifier ;
73
71
import com .swirlds .platform .components .appcomm .LatestCompleteStateNotifier ;
72
+ import com .swirlds .platform .components .consensus .ConsensusEngine ;
73
+ import com .swirlds .platform .components .consensus .DefaultConsensusEngine ;
74
74
import com .swirlds .platform .config .StateConfig ;
75
75
import com .swirlds .platform .config .TransactionConfig ;
76
76
import com .swirlds .platform .consensus .ConsensusSnapshot ;
82
82
import com .swirlds .platform .event .EventCounter ;
83
83
import com .swirlds .platform .event .GossipEvent ;
84
84
import com .swirlds .platform .event .creation .EventCreationManager ;
85
+ import com .swirlds .platform .event .linking .GossipLinker ;
85
86
import com .swirlds .platform .event .linking .InOrderLinker ;
86
87
import com .swirlds .platform .event .orphan .OrphanBuffer ;
87
88
import com .swirlds .platform .event .preconsensus .DefaultPcesSequencer ;
109
110
import com .swirlds .platform .listeners .PlatformStatusChangeNotification ;
110
111
import com .swirlds .platform .listeners .ReconnectCompleteNotification ;
111
112
import com .swirlds .platform .listeners .StateLoadedFromDiskNotification ;
112
- import com .swirlds .platform .metrics .ConsensusMetrics ;
113
- import com .swirlds .platform .metrics .ConsensusMetricsImpl ;
114
113
import com .swirlds .platform .metrics .RuntimeMetrics ;
115
114
import com .swirlds .platform .metrics .SwirldStateMetrics ;
116
115
import com .swirlds .platform .metrics .SyncMetrics ;
174
173
import java .util .Objects ;
175
174
import java .util .concurrent .ExecutionException ;
176
175
import java .util .concurrent .atomic .AtomicLong ;
177
- import java .util .concurrent .atomic .AtomicReference ;
178
176
import java .util .function .Consumer ;
179
177
import java .util .function .LongSupplier ;
180
178
import org .apache .logging .log4j .LogManager ;
@@ -197,12 +195,6 @@ public class SwirldsPlatform implements Platform {
197
195
*/
198
196
private final Shadowgraph shadowGraph ;
199
197
200
- /**
201
- * the object used to calculate consensus. it is volatile because the whole object is replaced when reading a state
202
- * from disk or getting it through reconnect
203
- */
204
- private final AtomicReference <Consensus > consensusRef = new AtomicReference <>();
205
-
206
198
/**
207
199
* the current nodes in the network and their information
208
200
*/
@@ -394,12 +386,10 @@ public SwirldsPlatform(@NonNull final PlatformComponentBuilder builder) {
394
386
395
387
registerAddressBookMetrics (metrics , currentAddressBook , selfId );
396
388
397
- final ConsensusMetrics consensusMetrics = new ConsensusMetricsImpl (selfId , metrics );
398
-
399
389
final SyncMetrics syncMetrics = new SyncMetrics (metrics );
400
390
RuntimeMetrics .setup (metrics );
401
391
402
- shadowGraph = new Shadowgraph (platformContext , currentAddressBook );
392
+ shadowGraph = new Shadowgraph (platformContext , currentAddressBook , blocks . intakeEventCounter () );
403
393
404
394
final EventConfig eventConfig = platformContext .getConfiguration ().getConfigData (EventConfig .class );
405
395
@@ -591,10 +581,11 @@ public SwirldsPlatform(@NonNull final PlatformComponentBuilder builder) {
591
581
initialState .getState ().getPlatformState ().getPreviousAddressBook (),
592
582
currentAddressBook ,
593
583
blocks .intakeEventCounter ());
584
+
594
585
final OrphanBuffer orphanBuffer = new OrphanBuffer (platformContext , blocks .intakeEventCounter ());
595
- final InOrderLinker inOrderLinker = new InOrderLinker (platformContext , time , blocks .intakeEventCounter ());
596
- final ConsensusEngine consensusEngine = new DefaultConsensusEngine (
597
- platformContext , selfId , consensusRef :: get , shadowGraph , blocks . intakeEventCounter (), e -> {} );
586
+ final InOrderLinker inOrderLinker = new GossipLinker (platformContext , blocks .intakeEventCounter ());
587
+
588
+ final ConsensusEngine consensusEngine = new DefaultConsensusEngine ( platformContext , currentAddressBook , selfId );
598
589
599
590
final LongSupplier intakeQueueSizeSupplier =
600
591
oldStyleIntakeQueue == null ? platformWiring .getIntakeQueueSizeSupplier () : oldStyleIntakeQueue ::size ;
@@ -717,8 +708,6 @@ public SwirldsPlatform(@NonNull final PlatformComponentBuilder builder) {
717
708
blocks .intakeEventCounter (),
718
709
() -> emergencyState .getState ("emergency reconnect" )) {};
719
710
720
- consensusRef .set (new ConsensusImpl (platformContext , consensusMetrics , getAddressBook ()));
721
-
722
711
latestImmutableStateNexus .setState (initialState .reserve ("set latest immutable to initial state" ));
723
712
724
713
if (startedFromGenesis ) {
0 commit comments