Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[NC-2058] initial scaffolding re block propagation #860

Merged
merged 12 commits into from
Feb 14, 2019

Conversation

smatthewenglish
Copy link
Contributor

PR description

comprises simple method, towards propagation of received blocks to connected peers

inspired by the existing pattern of the codebase, demonstrated here:

   @Override
    public void blockMined(final Block block) {
      // This assumes the block has already been included in the chain
  
      final Optional<UInt256> totalDifficulty = blockchain.getTotalDifficultyByHash(block.getHash());
      if (!totalDifficulty.isPresent()) {
        throw new IllegalStateException(
            "Unable to get total difficulty from blockchain for mined block.");
      }
  
      final NewBlockMessage newBlockMessage = NewBlockMessage.create(block, totalDifficulty.get());
  
      ethPeers
          .availablePeers()
          .forEach(
              peer -> {
                try {
                  peer.send(newBlockMessage);
                } catch (final PeerNotConnected ex) {
                  // Peers may disconnect while traversing the list, this is a normal occurrence.
                }
              });
    }

Fixed Issue(s)

@smatthewenglish smatthewenglish changed the title [NC-2058] [NC-2058] Initial scaffolding Feb 14, 2019
@smatthewenglish smatthewenglish changed the title [NC-2058] Initial scaffolding [NC-2058] initial scaffolding re block propagation Feb 14, 2019
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@smatthewenglish smatthewenglish merged commit c07e261 into PegaSysEng:master Feb 14, 2019
rain-on pushed a commit to rain-on/pantheon that referenced this pull request Feb 14, 2019
* o

* add test

* clean up

* scaffolding

* update

* update

* comments

* add test

* update

* update

* update
rain-on pushed a commit to rain-on/pantheon that referenced this pull request Feb 15, 2019
* o

* add test

* clean up

* scaffolding

* update

* update

* comments

* add test

* update

* update

* update
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants