You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sql.go
    path of file: ./repos/magma/lte/cloud/go/services/smsd/storage
    
    the code of the file until where you have to start completion: /*
 *  Copyright 2020 The Magma Authors.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree.
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" B
    
func (s *sqlSMSStorage) ReportDelivery(networkID string, deliveredMessages map[string][]SMSRef, failedMessages map[string][]SMSFailureReport) error {
	// TODO: what should we do in this case when we get a delivery digest for
	//  a message we don't know about?
	//  We probably don't want to error out the whole call
	txFn := func(tx *sql.Tx) (interface{}, error) {
		var allImsis []string
		for imsi := range deliveredMessages {
			allImsis = append(allImsis, imsi)
		}
		for imsi := range failedMessages {
			allImsis = append(allImsis, imsi)
		}
		allImsis = funk.UniqString(allImsis)

		// We need to map IMSI-ref_num back to message pk first
		pksByRef, err := loadPksByRefs(tx, s.builder, networkID, allImsis)
		if err != nil {
			return nil, err
		}

		err = markMessagesAsDelivered(tx, s.builder, networkID, deliveredMessages, pksByRef)
		if err != nil {
			return nil, err
		}

		err = processFailedMessages(tx, s.builder, networkID, failedMessages, pksByRef)
		if err != nil {
			return nil, err
		}

		return nil, nil
	}

	_, err := sqorc.ExecInTx(s.db, nil, nil, txFn)
	return err
}