reservoir

package
v0.15.6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: ISC Imports: 28 Imported by: 1

Documentation

Overview

Package reservoir - storage for: 1. pending transactions that are waiting to be verified 2. verified transactions that are waiting to be confirmed

Index

Constants

View Source
const (
	PayNonceHeightMask    uint64 = ^uint64(0x7f)
	PayNonceHeightDelta   uint64 = 0x80
	PayNonceHeightMinimum uint64 = 0xff
)

values to round block numbers

View Source
const (
	MaximumIssues = 100 // maximum allowable issues per block
)

various limiting constants

Variables

This section is empty.

Functions

func CheckGrantBalance added in v0.10.0

func CheckGrantBalance(trx storage.Transaction, grant *transactionrecord.ShareGrant, shareQuantityHandle storage.Handle) (uint64, error)

CheckGrantBalance - check sufficient balance to be able to execute a grant request

func CheckSwapBalances added in v0.10.0

func CheckSwapBalances(trx storage.Transaction, swap *transactionrecord.ShareSwap, shareQuantityHandle storage.Handle) (uint64, uint64, error)

CheckSwapBalances - check sufficient balance on both accounts to be able to execute a swap request

func ClearSpend added in v0.10.0

func ClearSpend()

ClearSpend - reset spend map

func DeleteByLink(link merkle.Digest)

DeleteByLink - remove a record using a link id

func DeleteByTxId added in v0.3.5

func DeleteByTxId(txId merkle.Digest)

DeleteByTxId - remove a record using a transaction id note, remove one issue in a block removes the whole issue block

func Disable added in v0.3.29

func Disable()

Disable - lock down to prevent proofer from getting data

func Enable added in v0.3.29

func Enable()

Enable - allow proofer to run again

func FetchVerified added in v0.3.5

func FetchVerified(count int) ([]merkle.Digest, []byte, error)

FetchVerified - fetch a series of verified transactions

func Finalise

func Finalise() error

Finalise - stop all background processes

func Initialise

func Initialise(cacheDirectory string, handles Handles, autoVerify bool) error

Initialise - create the cache

func LoadFromFile added in v0.11.0

func LoadFromFile(handles Handles) error

LoadFromFile - load transactions from file called later when system is able to handle the tx and proofs

func PayNonceRoundedHeight added in v0.13.0

func PayNonceRoundedHeight() uint64

get the rounded height

func ReadCounters added in v0.3.5

func ReadCounters() (int, int)

ReadCounters - for API to get status data

func Rescan added in v0.9.1

func Rescan()

Rescan - before calling Enable may need to run rescan to drop any invalidated transactions especially if the block height has changed

func ScaledDifficulty added in v0.3.30

func ScaledDifficulty(count int) *difficulty.Difficulty

ScaledDifficulty - produce a scaled difficulty based on the number of items in a block to be processed and include a quantity discount

func SetTransferVerified added in v0.5.0

func SetTransferVerified(payId pay.PayId, detail *PaymentDetail)

SetTransferVerified - set verified if transaction found, otherwise preserv payment for later

Types

type BalanceInfo added in v0.10.0

type BalanceInfo struct {
	ShareId   merkle.Digest `json:"shareId"`
	Confirmed uint64        `json:"confirmed"`
	Spend     uint64        `json:"spend"`
	Available uint64        `json:"available"`
}

BalanceInfo - result returned by store share

type GrantInfo added in v0.10.0

type GrantInfo struct {
	Remaining uint64
	Id        pay.PayId
	TxId      merkle.Digest
	Packed    []byte
	Payments  []transactionrecord.PaymentAlternative
}

GrantInfo - result returned by store share

type Handles added in v0.12.1

type Handles struct {
	Assets            storage.Handle
	BlockOwnerPayment storage.Handle
	Blocks            storage.Handle
	Transactions      storage.Handle
	OwnerTxIndex      storage.Handle
	OwnerData         storage.Handle
	Shares            storage.Handle
	ShareQuantity     storage.Handle
}

Handles - storage handles used when restore from cache file

type IssueInfo added in v0.3.5

type IssueInfo struct {
	TxIds      []merkle.Digest
	Packed     []byte
	Id         pay.PayId
	Nonce      PayNonce
	Difficulty *difficulty.Difficulty
	Payments   []transactionrecord.PaymentAlternative
}

IssueInfo - result returned by store issues

type PayNonce added in v0.3.30

type PayNonce [8]byte

PayNonce - type to represent a payment nonce Note: no reversal is required for this

func NewPayNonce added in v0.3.30

func NewPayNonce() PayNonce

NewPayNonce - create a random pay nonce

func PayNonceFromBlock added in v0.10.1

func PayNonceFromBlock(number uint64) PayNonce

PayNonceFromBlock - get a previous paynonce

func (PayNonce) GoString added in v0.3.30

func (paynonce PayNonce) GoString() string

GoString - convert a binary pay nonce to big endian hex string for use by the fmt package (for %#v)

func (PayNonce) MarshalText added in v0.3.30

func (paynonce PayNonce) MarshalText() ([]byte, error)

MarshalText - convert pay nonce to big endian hex text

func (PayNonce) String added in v0.3.30

func (paynonce PayNonce) String() string

String - convert a binary pay nonce to big endian hex string for use by the fmt package (for %s)

func (*PayNonce) UnmarshalText added in v0.3.30

func (paynonce *PayNonce) UnmarshalText(s []byte) error

UnmarshalText - convert little endian hex text into a pay nonce

type PaymentDetail added in v0.5.0

type PaymentDetail struct {
	Currency currency.Currency // code number
	TxID     string            // tx id on currency blockchain
	Amounts  map[string]uint64 // address(Base58) → value(Satoshis)
}

PaymentDetail - a payment record for a single currency

type PaymentSegment added in v0.5.0

type PaymentSegment [currency.Count]*transactionrecord.Payment

PaymentSegment - a single segment of a payment e.g. for an issue or transfer block owner

type Reservoir added in v0.13.0

type Reservoir interface {
	StoreTransfer(transactionrecord.BitmarkTransfer) (*TransferInfo, bool, error)
	StoreIssues(issues []*transactionrecord.BitmarkIssue) (*IssueInfo, bool, error)
	TryProof(pay.PayId, []byte) TrackingStatus
	TransactionStatus(merkle.Digest) TransactionState
	ShareBalance(*account.Account, merkle.Digest, int) ([]BalanceInfo, error)
	StoreGrant(*transactionrecord.ShareGrant) (*GrantInfo, bool, error)
	StoreSwap(swap *transactionrecord.ShareSwap) (*SwapInfo, bool, error)
}

Reservoir - APIs

func Get added in v0.13.0

func Get() Reservoir

Get - return reservoir APIs

type Restorer added in v0.12.1

type Restorer interface {
	Restore() error
	fmt.Stringer
}

Restorer - interface to restore data from cache file

func NewTransactionRestorer added in v0.12.1

func NewTransactionRestorer(unpacked interface{}, packed interface{}, handles Handles) (Restorer, error)

NewTransactionRestorer - create object with Restorer interface

type SwapInfo added in v0.10.0

type SwapInfo struct {
	RemainingOne uint64
	RemainingTwo uint64
	Id           pay.PayId
	TxId         merkle.Digest
	Packed       []byte
	Payments     []transactionrecord.PaymentAlternative
}

SwapInfo - result returned by store share

type TrackingStatus added in v0.3.30

type TrackingStatus int

TrackingStatus - result of track payment/try proof

const (
	TrackingNotFound  TrackingStatus = iota
	TrackingAccepted  TrackingStatus = iota
	TrackingProcessed TrackingStatus = iota
	TrackingInvalid   TrackingStatus = iota
)

possible status values

func (TrackingStatus) MarshalText added in v0.3.30

func (ts TrackingStatus) MarshalText() ([]byte, error)

MarshalText - convert the tracking value for JSON

func (TrackingStatus) String added in v0.3.30

func (ts TrackingStatus) String() string

String - convert the tracking value for printf

func (*TrackingStatus) UnmarshalText added in v0.3.30

func (ts *TrackingStatus) UnmarshalText(s []byte) error

UnmarshalText - convert the tracking value from JSON to enumeration

type TransactionState added in v0.3.30

type TransactionState int

TransactionState - status enumeration

const (
	StateUnknown   TransactionState = iota
	StatePending   TransactionState = iota
	StateVerified  TransactionState = iota
	StateConfirmed TransactionState = iota
)

list of all states

func (TransactionState) String added in v0.3.30

func (state TransactionState) String() string

String - string representation of a transaction state

type TransferInfo added in v0.3.5

type TransferInfo struct {
	Id        pay.PayId
	TxId      merkle.Digest
	IssueTxId merkle.Digest
	Packed    []byte
	Payments  []transactionrecord.PaymentAlternative
}

TransferInfo - result returned by store transfer

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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