storage

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStateMgr

type FileStateMgr struct {
	// contains filtered or unexported fields
}

FileStateMgr save the local state to file

func NewFileStateMgr

func NewFileStateMgr(folder string) (*FileStateMgr, error)

NewFileStateMgr create a new instance of the FileStateMgr which implements LocalStateManager

func (*FileStateMgr) GetLocalState

func (fsm *FileStateMgr) GetLocalState(pubKey string) (KeygenLocalState, error)

GetLocalState read the local state from file system

func (*FileStateMgr) RetrieveP2PAddresses

func (fsm *FileStateMgr) RetrieveP2PAddresses() (p2p.AddrList, error)

func (*FileStateMgr) SaveAddressBook

func (fsm *FileStateMgr) SaveAddressBook(address map[peer.ID]p2p.AddrList) error

func (*FileStateMgr) SaveLocalState

func (fsm *FileStateMgr) SaveLocalState(state KeygenLocalState) error

SaveLocalState save the local state to file

type KeygenLocalState

type KeygenLocalState struct {
	PubKey          string                    `json:"pub_key"`
	LocalData       keygen.LocalPartySaveData `json:"local_data"`
	ParticipantKeys []string                  `json:"participant_keys"` // the paticipant of last key gen
	LocalPartyKey   string                    `json:"local_party_key"`
}

KeygenLocalState is a structure used to represent the data we saved locally for different keygen

type LocalStateManager

type LocalStateManager interface {
	SaveLocalState(state KeygenLocalState) error
	GetLocalState(pubKey string) (KeygenLocalState, error)
	SaveAddressBook(addressBook map[peer.ID]p2p.AddrList) error
	RetrieveP2PAddresses() (p2p.AddrList, error)
}

LocalStateManager provide necessary methods to manage the local state, save it , and read it back LocalStateManager doesn't have any opinion in regards to where it should be persistent to

type MockLocalStateManager

type MockLocalStateManager struct {
}

MockLocalStateManager is a mock use for test purpose

func (*MockLocalStateManager) GetLocalState

func (s *MockLocalStateManager) GetLocalState(pubKey string) (KeygenLocalState, error)

func (*MockLocalStateManager) RetrieveP2PAddresses

func (s *MockLocalStateManager) RetrieveP2PAddresses() (p2p.AddrList, error)

func (*MockLocalStateManager) SaveAddressBook

func (s *MockLocalStateManager) SaveAddressBook(address map[peer.ID]p2p.AddrList) error

func (*MockLocalStateManager) SaveLocalState

func (s *MockLocalStateManager) SaveLocalState(state KeygenLocalState) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL