Skip to content

Commit

Permalink
Proof of Stake banner (#3757)
Browse files Browse the repository at this point in the history
* i did it for the gram

Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
jflo authored May 9, 2022
1 parent 1efe1f0 commit b543983
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.merge.FinalizedBlockHashSupplier;
import org.hyperledger.besu.consensus.merge.MergeContext;
import org.hyperledger.besu.consensus.merge.PandaPrinter;
import org.hyperledger.besu.consensus.qbft.pki.PkiBlockCreationConfiguration;
import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
Expand Down Expand Up @@ -340,6 +341,7 @@ public BesuController build() {
final boolean fastSyncEnabled =
EnumSet.of(SyncMode.FAST, SyncMode.X_SNAP).contains(syncConfig.getSyncMode());
final SyncState syncState = new SyncState(blockchain, ethPeers, fastSyncEnabled);
syncState.subscribeTTDReached(new PandaPrinter());

final TransactionPool transactionPool =
TransactionPoolFactory.createTransactionPool(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

package org.hyperledger.besu.consensus.merge;

import org.hyperledger.besu.plugin.services.BesuEvents.TTDReachedListener;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PandaPrinter implements TTDReachedListener {

private static final Logger LOG = LoggerFactory.getLogger(PandaPrinter.class);
private static final String pandaBanner = PandaPrinter.loadBanner();

private static String loadBanner() {
Class<PandaPrinter> c = PandaPrinter.class;
InputStream is = c.getResourceAsStream("/ProofOfPanda3.txt");
StringBuilder resultStringBuilder = new StringBuilder();
try (BufferedReader br =
new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
resultStringBuilder.append(line).append("\n");
}
} catch (IOException e) {
LOG.error("Couldn't load hilarious panda banner");
}
return resultStringBuilder.toString();
}

@Override
public void onTTDReached(final boolean reached) {
if (reached) {
LOG.info("\n" + pandaBanner);
}
}
}
Loading

0 comments on commit b543983

Please sign in to comment.