Beispiel #1
0
// joinChain will join the specified chain in the configuration block.
// Since it is the first block, it is the genesis block containing configuration
// for this chain, so we want to update the Chain object with this info
func joinChain(blockBytes []byte) ([]byte, error) {
	if blockBytes == nil {
		return nil, fmt.Errorf("Genesis block must not be nil.")
	}

	block, err := utils.GetBlockFromBlockBytes(blockBytes)
	if err != nil {
		return nil, fmt.Errorf("Failed to reconstruct the genesis block, %s", err)
	}

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

	return nil, nil
}
Beispiel #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
}