store

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Overview

Package store contains the interface for a go-nitro store.

Index

Constants

View Source
const (
	ErrNoSuchObjective = types.ConstError("store: no such objective")
	ErrNoSuchChannel   = types.ConstError("store: failed to find required channel data")
	ErrLoadVouchers    = types.ConstError("store: could not load vouchers")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsensusChannelStore

type ConsensusChannelStore interface {
	GetAllConsensusChannels() ([]*consensus_channel.ConsensusChannel, error)
	GetConsensusChannel(counterparty types.Address) (channel *consensus_channel.ConsensusChannel, ok bool)
	GetConsensusChannelById(id types.Destination) (channel *consensus_channel.ConsensusChannel, err error)
	SetConsensusChannel(*consensus_channel.ConsensusChannel) error
	DestroyConsensusChannel(id types.Destination) error
}

type DurableStore

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

func (*DurableStore) Close

func (ds *DurableStore) Close() error

func (*DurableStore) DestroyChannel

func (ds *DurableStore) DestroyChannel(id types.Destination) error

DestroyChannel deletes the channel with id id.

func (*DurableStore) DestroyConsensusChannel

func (ds *DurableStore) DestroyConsensusChannel(id types.Destination) error

DestroyChannel deletes the channel with id id.

func (*DurableStore) GetAddress

func (ds *DurableStore) GetAddress() *types.Address

func (*DurableStore) GetAllConsensusChannels

func (ds *DurableStore) GetAllConsensusChannels() ([]*consensus_channel.ConsensusChannel, error)

func (*DurableStore) GetChannelById

func (ds *DurableStore) GetChannelById(id types.Destination) (c *channel.Channel, ok bool)

GetChannelById retrieves the channel with the supplied id, if it exists.

func (*DurableStore) GetChannelSecretKey

func (ds *DurableStore) GetChannelSecretKey() *[]byte

func (*DurableStore) GetChannelsByAppDefinition

func (ds *DurableStore) GetChannelsByAppDefinition(appDef types.Address) ([]*channel.Channel, error)

GetChannelsByAppDefinition returns any channels that include the given app definition

func (*DurableStore) GetChannelsByIds

func (ds *DurableStore) GetChannelsByIds(ids []types.Destination) ([]*channel.Channel, error)

GetChannelsByIds returns any channels with ids in the supplied list.

func (*DurableStore) GetChannelsByParticipant

func (ds *DurableStore) GetChannelsByParticipant(participant types.Address) ([]*channel.Channel, error)

GetChannelsByParticipant returns any channels that include the given participant

func (*DurableStore) GetConsensusChannel

func (ps *DurableStore) GetConsensusChannel(counterparty types.Address) (channel *consensus_channel.ConsensusChannel, ok bool)

GetConsensusChannel returns a ConsensusChannel between the calling node and the supplied counterparty, if such channel exists

func (*DurableStore) GetConsensusChannelById

func (ds *DurableStore) GetConsensusChannelById(id types.Destination) (channel *consensus_channel.ConsensusChannel, err error)

GetConsensusChannelById returns a ConsensusChannel with the given channel id

func (*DurableStore) GetLastBlockNumSeen

func (ds *DurableStore) GetLastBlockNumSeen() (uint64, error)

GetLastBlockNumSeen retrieves the last blockchain block processed by this node

func (*DurableStore) GetObjectiveByChannelId

func (ps *DurableStore) GetObjectiveByChannelId(channelId types.Destination) (protocols.Objective, bool)

func (*DurableStore) GetObjectiveById

func (ds *DurableStore) GetObjectiveById(id protocols.ObjectiveId) (protocols.Objective, error)

func (*DurableStore) GetVoucherInfo

func (ds *DurableStore) GetVoucherInfo(channelId types.Destination) (*payments.VoucherInfo, error)

func (*DurableStore) ReleaseChannelFromOwnership

func (ds *DurableStore) ReleaseChannelFromOwnership(channelId types.Destination) error

func (*DurableStore) RemoveVoucherInfo

func (ds *DurableStore) RemoveVoucherInfo(channelId types.Destination) error

func (*DurableStore) SetChannel

func (ds *DurableStore) SetChannel(ch *channel.Channel) error

SetChannel sets the channel in the store.

func (*DurableStore) SetConsensusChannel

func (ps *DurableStore) SetConsensusChannel(ch *consensus_channel.ConsensusChannel) error

SetConsensusChannel sets the channel in the store.

func (*DurableStore) SetLastBlockNumSeen

func (ds *DurableStore) SetLastBlockNumSeen(blockNumber uint64) error

SetLastBlockNumSeen sets the last blockchain block processed by this node

func (*DurableStore) SetObjective

func (ds *DurableStore) SetObjective(obj protocols.Objective) error

func (*DurableStore) SetVoucherInfo

func (ds *DurableStore) SetVoucherInfo(channelId types.Destination, v payments.VoucherInfo) error

type MemStore

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

func (*MemStore) Close

func (ms *MemStore) Close() error

func (*MemStore) DestroyChannel

func (ms *MemStore) DestroyChannel(id types.Destination) error

DestroyChannel deletes the channel with id id.

func (*MemStore) DestroyConsensusChannel

func (ms *MemStore) DestroyConsensusChannel(id types.Destination) error

DestroyChannel deletes the channel with id id.

func (*MemStore) GetAddress

func (ms *MemStore) GetAddress() *types.Address

func (*MemStore) GetAllConsensusChannels

func (ms *MemStore) GetAllConsensusChannels() ([]*consensus_channel.ConsensusChannel, error)

func (*MemStore) GetChannelById

func (ms *MemStore) GetChannelById(id types.Destination) (c *channel.Channel, ok bool)

GetChannelById retrieves the channel with the supplied id, if it exists.

func (*MemStore) GetChannelSecretKey

func (ms *MemStore) GetChannelSecretKey() *[]byte

func (*MemStore) GetChannelsByAppDefinition

func (ms *MemStore) GetChannelsByAppDefinition(appDef types.Address) ([]*channel.Channel, error)

GetChannelsByAppDefinition returns any channels that include the given app definition

func (*MemStore) GetChannelsByIds

func (ms *MemStore) GetChannelsByIds(ids []types.Destination) ([]*channel.Channel, error)

GetChannelsByIds returns a collection of channels with the given ids

func (*MemStore) GetChannelsByParticipant

func (ms *MemStore) GetChannelsByParticipant(participant types.Address) ([]*channel.Channel, error)

GetChannelsByParticipant returns any channels that include the given participant

func (*MemStore) GetConsensusChannel

func (ms *MemStore) GetConsensusChannel(counterparty types.Address) (channel *consensus_channel.ConsensusChannel, ok bool)

GetConsensusChannel returns a ConsensusChannel between the calling node and the supplied counterparty, if such channel exists

func (*MemStore) GetConsensusChannelById

func (ms *MemStore) GetConsensusChannelById(id types.Destination) (channel *consensus_channel.ConsensusChannel, err error)

GetConsensusChannelById returns a ConsensusChannel with the given channel id

func (*MemStore) GetLastBlockNumSeen

func (ms *MemStore) GetLastBlockNumSeen() (uint64, error)

GetLastBlockNumSeen

func (*MemStore) GetObjectiveByChannelId

func (ms *MemStore) GetObjectiveByChannelId(channelId types.Destination) (protocols.Objective, bool)

func (*MemStore) GetObjectiveById

func (ms *MemStore) GetObjectiveById(id protocols.ObjectiveId) (protocols.Objective, error)

func (*MemStore) GetVoucherInfo

func (ms *MemStore) GetVoucherInfo(channelId types.Destination) (*payments.VoucherInfo, error)

func (*MemStore) ReleaseChannelFromOwnership

func (ms *MemStore) ReleaseChannelFromOwnership(channelId types.Destination) error

func (*MemStore) RemoveVoucherInfo

func (ms *MemStore) RemoveVoucherInfo(channelId types.Destination) error

func (*MemStore) SetChannel

func (ms *MemStore) SetChannel(ch *channel.Channel) error

SetChannel sets the channel in the store.

func (*MemStore) SetConsensusChannel

func (ms *MemStore) SetConsensusChannel(ch *consensus_channel.ConsensusChannel) error

SetConsensusChannel sets the channel in the store.

func (*MemStore) SetLastBlockNumSeen

func (ms *MemStore) SetLastBlockNumSeen(blockNumber uint64) error

SetLastBlockNumSeen

func (*MemStore) SetObjective

func (ms *MemStore) SetObjective(obj protocols.Objective) error

func (*MemStore) SetVoucherInfo

func (ms *MemStore) SetVoucherInfo(channelId types.Destination, v payments.VoucherInfo) error

type Store

type Store interface {
	GetChannelSecretKey() *[]byte                                                 // Get a pointer to a secret key for signing channel updates
	GetAddress() *types.Address                                                   // Get the (Ethereum) address associated with the ChannelSecretKey
	GetObjectiveById(protocols.ObjectiveId) (protocols.Objective, error)          // Read an existing objective
	GetObjectiveByChannelId(types.Destination) (obj protocols.Objective, ok bool) // Get the objective that currently owns the channel with the supplied ChannelId
	SetObjective(protocols.Objective) error                                       // Write an objective
	GetChannelsByIds(ids []types.Destination) ([]*channel.Channel, error)         // Returns a collection of channels with the given ids
	GetChannelById(id types.Destination) (c *channel.Channel, ok bool)
	GetChannelsByParticipant(participant types.Address) ([]*channel.Channel, error) // Returns any channels that includes the given participant
	SetChannel(*channel.Channel) error
	DestroyChannel(id types.Destination) error
	GetChannelsByAppDefinition(appDef types.Address) ([]*channel.Channel, error) // Returns any channels that includes the given app definition
	ReleaseChannelFromOwnership(types.Destination) error                         // Release channel from being owned by any objective
	GetLastBlockNumSeen() (uint64, error)
	SetLastBlockNumSeen(uint64) error

	ConsensusChannelStore
	payments.VoucherStore
	io.Closer
}

Store is responsible for persisting objectives, objective metadata, states, signatures, private keys and blockchain data

func NewDurableStore

func NewDurableStore(key []byte, folder string, config buntdb.Config) (Store, error)

NewDurableStore creates a new DurableStore that uses the given folder to store its data It will create the folder if it does not exist

func NewMemStore

func NewMemStore(key []byte) Store

func NewStore

func NewStore(options StoreOpts) (Store, error)

type StoreOpts added in v0.1.2

type StoreOpts struct {
	PkBytes            []byte
	UseDurableStore    bool
	DurableStoreFolder string
	BuntDbConfig       buntdb.Config
}

Jump to

Keyboard shortcuts

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