storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const SubmittedTxStatusPrefix = "submitted_txs"

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyStorage

type DummyStorage struct {
	KVUpdateMap map[uint64]uint64
}

func NewDummyStorage

func NewDummyStorage() *DummyStorage

func (*DummyStorage) Close

func (s *DummyStorage) Close() error

func (*DummyStorage) GetAllPendingTxs

func (s *DummyStorage) GetAllPendingTxs() ([]*relay.PendingSubmittedTxInfo, error)

func (*DummyStorage) GetLastQueryHeight

func (s *DummyStorage) GetLastQueryHeight(queryID uint64) (uint64, bool, error)

func (*DummyStorage) SetLastQueryHeight

func (s *DummyStorage) SetLastQueryHeight(queryID uint64, block uint64) error

func (*DummyStorage) SetTxStatus

func (s *DummyStorage) SetTxStatus(queryID uint64, hash string, neutronHash string, status relay.SubmittedTxInfo) (err error)

func (*DummyStorage) TxExists

func (s *DummyStorage) TxExists(queryID uint64, hash string) (exists bool, err error)

type LevelDBStorage

type LevelDBStorage struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LevelDBStorage Basically has a simple structure inside: we have 2 maps first one : map of queryID -> last block this query has been processed second one: map of queryID+txHash -> status of sent tx

func NewLevelDBStorage

func NewLevelDBStorage(path string) (*LevelDBStorage, error)

func (*LevelDBStorage) Close

func (s *LevelDBStorage) Close() error

func (*LevelDBStorage) GetAllPendingTxs

func (s *LevelDBStorage) GetAllPendingTxs() ([]*relay.PendingSubmittedTxInfo, error)

func (*LevelDBStorage) GetLastQueryHeight

func (s *LevelDBStorage) GetLastQueryHeight(queryID uint64) (block uint64, found bool, err error)

GetLastQueryHeight returns last update block for KV query

func (*LevelDBStorage) SetLastQueryHeight

func (s *LevelDBStorage) SetLastQueryHeight(queryID uint64, block uint64) error

SetLastQueryHeight sets last processed block to given query

func (*LevelDBStorage) SetTxStatus

func (s *LevelDBStorage) SetTxStatus(queryID uint64, hash string, neutronHash string, status relay.SubmittedTxInfo) (err error)

SetTxStatus sets status for given tx queryID + hash can be one of 4 statuses:

  1. Error while submitting tx - relay.ErrorOnSubmit
  2. tx submitted successfully (temporary status, should be updated after neutron tx committed into the block) - relay.Submitted 2.a) failed to commit tx into the block - relay.ErrorOnCommit 2.b) tx successfully committed - relay.Committed

To convert status from "2" to either "2.a" or "2.b" we use additional SubmittedTxStatusPrefix storage to track txs

func (*LevelDBStorage) TxExists

func (s *LevelDBStorage) TxExists(queryID uint64, hash string) (exists bool, err error)

TxExists returns if tx has been processed

Jump to

Keyboard shortcuts

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