func (c *Recorder) SaveEvent(connectionID string, data []byte) error {
	return c.protocolStateStore.Put(getEventDataKeyPrefix()(connectionID), data)
}
SaveEvent saves event related data for given connection ID
TODO connection event data shouldn't be transient [Issues #1029].
package connection
import (
	"crypto"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/hyperledger/aries-framework-go/spi/storage"
)
const (
	StateNameCompleted = "completed"
	MyNSPrefix = "my"
	TheirNSPrefix    = "their"
	errMsgInvalidKey = "invalid key"
)
func NewRecorder(p provider) (*Recorder, error) {
	lookup, err := NewLookup(p)
	if err != nil {
		return nil, fmt.Errorf("failed to create new connection recorder : %w", err)
	}
	return &Recorder{lookup}, nil
}
type Recorder struct {
	*Lookup
}
func (c *Recorder) SaveInvitation(id string, invitation interface{}) error {
	if id == "" {
		return fmt.Errorf(errMsgInvalidKey)
	}
	return marshalAndSave(getInvitationKeyPrefix()(id), invitation, c.store)
}
func (c *Recorder) SaveConnectionRecord(record *Record) error {
	if err := marshalAndSave(getConnectionKeyPrefix()(record.ConnectionID),
		record, c.protocolStateStore, storage.Tag{
			Name:  getConnectionKeyPrefix()(""),
			Value: getConnectionKeyPrefix()(record.ConnectionID),
		}); err != nil {
		return fmt.Errorf("save connection record in protocol state store: %w", err)
	}
	if record.State != "" {
		err := marshalAndSave(getConnectionStateKeyPrefix()(record.ConnectionID, record.State),
			record, c.protocolStateStore, storage.Tag{
				Name:  connStateKeyPrefix,
				Value: getConnectionStateKeyPrefix()(record.ConnectionID),
			})
		if err != nil {
			return fmt.Errorf("save connection record with state in protocol state store: %w", err)
		}
	}
	if record.State == StateNameCompleted {
		if err := marshalAndSave(getConnectionKeyPrefix()(record.ConnectionID),
			record, c.store, storage.Tag{
				Name:  getConnectionKeyPrefix()(""),
				Value: getConnectionKeyPrefix()(record.ConnectionID),
			},
			storage.Tag{
				Name:  bothDIDsTagName,
				Value: tagValueFromDIDs(record.MyDID, record.TheirDID),
			},
			storage.Tag{
				Name:  theirDIDTagName,
				Value: tagValueFromDIDs(record.TheirDID),
			}); err != nil {
			return fmt.Errorf("save connection record in permanent store: %w", err)
		}
	}
	return nil
}
func (c *Recorder) SaveConnectionRecordWithMappings(record *Record) error {
	err := isValidConnection(record)
	if err != nil {
		return fmt.Errorf("validation failed while saving connection record with mapping: %w", err)
	}
	err = c.SaveConnectionRecord(record)
	if err != nil {
		return fmt.Errorf("failed to save connection record with mappings: %w", err)
	}
	err = c.SaveNamespaceThreadID(record.ThreadID, record.Namespace, record.ConnectionID)
	if err != nil {
		return fmt.Errorf("failed to save connection record with namespace mappings: %w", err)
	}
	return nil
}