示例#1
0
// JoinChannel joins the channel and initialize gossip state with given committer
func (g *gossipServiceImpl) JoinChannel(commiter committer.Committer, block *common.Block) error {
	g.lock.Lock()
	defer g.lock.Unlock()

	if chainID, err := utils.GetChainIDFromBlock(block); err != nil {
		return err
	} else {
		// Initialize new state provider for given committer
		g.chains[chainID] = state.NewGossipStateProvider(g.gossip, commiter)
	}

	return nil
}
示例#2
0
func updateConfigBlock(blockBytes []byte) ([]byte, error) {
	if blockBytes == nil {
		return nil, errors.New("Configuration block must not be nil.")
	}
	block, err := utils.GetBlockFromBlockBytes(blockBytes)
	if err != nil {
		return nil, fmt.Errorf("Failed to reconstruct the configuration block, %s", err)
	}
	chainID, err := utils.GetChainIDFromBlock(block)
	if err != nil {
		return nil, fmt.Errorf("Failed to get the chain ID from the configuration block, %s", err)
	}

	if err := peer.SetCurrConfigBlock(block, chainID); err != nil {
		return nil, err
	}

	// TODO: would committer get ledger and update ?

	return nil, nil
}