Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gossip #16

Open
yfhk opened this issue Nov 22, 2018 · 0 comments
Open

gossip #16

yfhk opened this issue Nov 22, 2018 · 0 comments

Comments

@yfhk
Copy link
Owner

yfhk commented Nov 22, 2018

	case *orderer.DeliverResponse_Block:
		errorStatusCounter = 0
		statusCounter = 0
		seqNum := t.Block.Header.Number

		marshaledBlock, err := proto.Marshal(t.Block)
		if err != nil {
			logger.Errorf("[%s] Error serializing block with sequence number %d, due to %s", b.chainID, seqNum, err)
			continue
		}
		if err := b.mcs.VerifyBlock(gossipcommon.ChainID(b.chainID), seqNum, marshaledBlock); err != nil {
			logger.Errorf("[%s] Error verifying block with sequnce number %d, due to %s", b.chainID, seqNum, err)
			continue
		}

		//add by huxiao			
		record.RecordNewBlockToFile(t.Block)

		numberOfPeers := len(b.gossip.PeersOfChannel(gossipcommon.ChainID(b.chainID)))
		// Create payload with a block received
		payload := createPayload(seqNum, marshaledBlock)
		// Use payload to create gossip message
		gossipMsg := createGossipMsg(b.chainID, payload)

		logger.Debugf("[%s] Adding payload locally, buffer seqNum = [%d], peers number [%d]", b.chainID, seqNum, numberOfPeers)
		// Add payload to local state payloads buffer
		if err := b.gossip.AddPayload(b.chainID, payload); err != nil {
			logger.Warning("Failed adding payload of", seqNum, "because:", err)
		}

		// Gossip messages with other nodes
		logger.Debugf("[%s] Gossiping block [%d], peers number [%d]", b.chainID, seqNum, numberOfPeers)
		b.gossip.Gossip(gossipMsg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant