func (d *DbFake) SaveMerkleCommitments(commitments []models.CommitmentMerkleCommitment) error {
	var newCommitments []models.CommitmentMerkleCommitment
	for _, commitment := range commitments {
		found := false
		for i, c := range d.MerkleCommitments {
			if c == commitment {
				found = true
				d.MerkleCommitments[i] = commitment
				break
			}
		}
		if !found {
			newCommitments = append(newCommitments, commitment)
		}
	}
	d.MerkleCommitments = append(d.MerkleCommitments, newCommitments...)
	return nil
}
Save merkle commitments to the MerkleCommitment collection
package db
import (
	"errors"
	"mainstay/models"
	"github.com/btcsuite/btcd/chaincfg/chainhash"
)
type DbFake struct {
	Attestations      []models.Attestation
	AttestationsInfo  []models.AttestationInfo
	MerkleCommitments []models.CommitmentMerkleCommitment
	MerkleProofs      []models.CommitmentMerkleProof
	latestCommitments []models.ClientCommitment
}
func NewDbFake() *DbFake {
	return &DbFake{
		[]models.Attestation{},
		[]models.AttestationInfo{},
		[]models.CommitmentMerkleCommitment{},
		[]models.CommitmentMerkleProof{},
		[]models.ClientCommitment{}}
}
func (d *DbFake) SaveAttestation(attestation models.Attestation) error {
	for i, a := range d.Attestations {
		if a.Txid == attestation.Txid {
			d.Attestations[i] = attestation
			return nil
		}
	}
	d.Attestations = append(d.Attestations, attestation)
	return nil
}
func (d *DbFake) SaveAttestationInfo(attestationInfo models.AttestationInfo) error {
	for i, a := range d.AttestationsInfo {
		if a.Txid == attestationInfo.Txid {
			d.AttestationsInfo[i] = attestationInfo
			return nil
		}
	}
	d.AttestationsInfo = append(d.AttestationsInfo, attestationInfo)
	return nil
}