func (t *Torrent) maybeCompleteMetadata() error {
	if t.haveInfo() {
		// Nothing to do.
		return nil
	}
	if !t.haveAllMetadataPieces() {
		// Don't have enough metadata pieces.
		return nil
	}
	err := t.setInfoBytes(t.metadataBytes)
	if err != nil {
		t.invalidateMetadata()
		return fmt.Errorf("error setting info bytes: %s", err)
	}
	if t.cl.config.Debug {
		t.logger.Printf("%s: got metadata from peers", t)
	}
	return nil
}
// Returns an error if the metadata was completed, but couldn't be set for
// some reason. Blame it on the last peer to contribute.
Returns an error if the metadata was completed, but couldn't be set for
some reason. Blame it on the last peer to contribute.
// Returns an error if the metadata was completed but couldn ' t be set for // some reason . Blame it on the last peer to contribute .
func (t *Torrent) maybeCompleteMetadata() error {
	if t.haveInfo() {
		return nil
	}
	if !t.haveAllMetadataPieces() {
		return nil
	}
	err := t.setInfoBytes(t.metadataBytes)
	if err != nil {
		t.invalidateMetadata()
		return fmt.Errorf("error setting info bytes: %s", err)
	}
	if t.cl.config.Debug {
		t.logger.Printf("%s: got metadata from peers", t)
	}
	return nil
}
func ( t * Torrent ) maybeCompleteMetadata ( ) error { if t . haveInfo ( ) { return nil } if ! t . haveAllMetadataPieces ( ) { return nil } err := t . setInfoBytes ( t . metadataBytes ) if err != nil { t . invalidateMetadata ( ) return fmt . Errorf ( " " , err ) } if t . cl . config . Debug { t . logger . Printf ( " " , t ) } return nil }
Returns an error if the metadata was completed, but couldn't be set for
some reason.
Returns an error if the metadata was completed but couldn ' t be set for some reason .
// Nothing to do. // Don't have enough metadata pieces.