storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubmittedTxStatusPrefix    = "submitted_txs"
	UnsuccessfulTxStatusPrefix = "unsuccessful_txs"
	CachedTxs                  = "cached_txs"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LevelDBStorage

type LevelDBStorage struct {
	// 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) GetAllUnsuccessfulTxs added in v0.2.0

func (s *LevelDBStorage) GetAllUnsuccessfulTxs() ([]*relay.UnsuccessfulTxInfo, error)

func (*LevelDBStorage) GetCachedTx added in v0.2.0

func (s *LevelDBStorage) GetCachedTx(queryID uint64, hash string) (*relay.Transaction, error)

GetCachedTx returns a cached remote tx

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, txInfo relay.SubmittedTxInfo, processedTx *relay.Transaction) (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