dgxpricing

package module
v0.0.0-...-6ef9485 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2018 License: MIT Imports: 7 Imported by: 2

README

dgx-price-feeder

Prerequisites

  1. Docker and Docker compose
  2. A json keystore file
  3. A passphrase file (the file should contain only the passphrase, note that the app will remove leading spaces, trailing spaces and new lines so please make sure your passphrase doesn't have such characters)

Install

  1. Copy the keystore to <repo_root>/cmd/keystore
  2. Copy the passphrase to <repo_root>/cmd/passphrase
  3. Assume you are in <repo_root>, run docker-compose build to build the image
  4. docker-compose run -d to run the price feeder

Where: <repo_root> is the path to this repo. Note: cmd/keystore and cmd/passphrase are ignored by the .gitignore to avoid mistakenly committing the credentical to git.

Log

The log will be written to <repo_root>/log and will be rotated daily.

Documentation

Index

Constants

View Source
const (
	NO_RETRY int = 6
	// INIT_GASPRICE int64 = 1000000000 // 1gwei
	INIT_GASPRICE int64 = 4000000000  // 4gwei
	GASPRICE_STEP int64 = 15700000000 // 15.7gwei
	NO_STEP       int   = 3
	// TX_WAIT_TIME  uint64 = 10 // 10 seconds
	TX_WAIT_TIME uint64 = 10 * 60 // 10 minutes
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockchain

type Blockchain interface {
	// status should be:
	// 1. "": pending
	// 2. lost: not found from the node
	// 3. mined: successfully
	// 4. failed: threw/reverted
	TxStatus(common.Hash) (status string, blockno uint64, err error)
}

type PriceCorpus

type PriceCorpus interface {
	GetFeed() (blockNumber *big.Int, nonce *big.Int, ask1KDigix *big.Int, bid1KDigix *big.Int, v uint8, r [32]byte, s [32]byte, err error)
}

type PriceFeeder

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

func NewPriceFeeder

func NewPriceFeeder(runner Runner, reserve Reserve, prices PriceCorpus) *PriceFeeder

func (*PriceFeeder) EnsureFeedPrice

func (self *PriceFeeder) EnsureFeedPrice()

func (*PriceFeeder) MonitorAndRetry

func (self *PriceFeeder) MonitorAndRetry(tx *types.Transaction) error

func (*PriceFeeder) Run

func (self *PriceFeeder) Run()

func (*PriceFeeder) Stop

func (self *PriceFeeder) Stop()

func (*PriceFeeder) TryFeedingPrice

func (self *PriceFeeder) TryFeedingPrice() (*types.Transaction, error)

type Reserve

type Reserve interface {
	SetPriceFeed(gasPrice *big.Int, blockNumber *big.Int, nonce *big.Int, ask1KDigix *big.Int, bid1KDigix *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error)
	TxStatus(common.Hash) (status string, blockno uint64, err error)
	Rebroadcast(tx *types.Transaction) (*types.Transaction, error)
}

type Runner

type Runner interface {
	GetPricingTicker() <-chan time.Time
	Start() error
	Stop() error
}

type StatusMonitor

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

StatusMonitor is not thread safe

func NewStatusMonitor

func NewStatusMonitor(initTx *types.Transaction) *StatusMonitor

func (*StatusMonitor) ConcurrentlyGetStatus

func (self *StatusMonitor) ConcurrentlyGetStatus(bc Blockchain) map[string]string

func (*StatusMonitor) GetOneStatus

func (self *StatusMonitor) GetOneStatus(tx *types.Transaction, bc Blockchain, data *sync.Map, wg *sync.WaitGroup)

func (*StatusMonitor) GetStatus

func (self *StatusMonitor) GetStatus(bc Blockchain) (st string, tx *types.Transaction, err error)

GetStatus query statuses of all txs, it returns: 1. mined: if one of the txs is mined 2. failed: if one of the txs is failed 3. lost: if not in the case of 1 nor 2 and the last tx is not found 4. pending: if not in the case of 1 nor 2 nor 3 and the last tx is pending

func (*StatusMonitor) GetTxByHash

func (self *StatusMonitor) GetTxByHash(hash string) *types.Transaction

func (*StatusMonitor) PushTx

func (self *StatusMonitor) PushTx(tx *types.Transaction) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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