workers

package
v0.0.0-...-019d704 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxUnshieldFee                  = 500000
	InitIncBlockBatchSize           = 100
	FirstBroadcastTxBlockHeight     = 1427305
	TimeoutBTCFeeReplacement        = 80
	TimeIntervalBTCFeeReplacement   = 10
	BroadcastingManagerDBFileDir    = "db/broadcastingmanager"
	BroadcastingManagerDBObjectName = "BTCBroadcast-LastUpdate"
)
View Source
const (
	BTCBlockBatchSize = 10 // BTCBlockBatchSize is BTC block batch size
	BlockStepBacks    = 8  // BlockStepBacks is number of blocks that the job needs to step back to solve fork situation
)
View Source
const (
	FirstScannedBTCBlkHeight        = 697200
	TimeoutTrackingInstanceInSecond = int64(365 * 24 * 60 * 60)
	WalletMonitorDBFileDir          = "db/walletmonitor"
	WalletMonitorDBObjectName       = "BTCMonitor-LastUpdate"
	MinShieldAmount                 = 100000 // nano pBTC
)
View Source
const (
	BTCID                    = "b832e5d3b1f01a4f0623f7fe91d6673461e1f5d37d91fe78c5c2e6183ff39696"
	BTCConfirmationThreshold = 6

	NumGetStatusTries = 3
	IntervalTries     = 1 * time.Minute
)
View Source
const (
	BTCBlockDiffThreshold        = 3
	CheckRelayingIntervalSeconds = 30 * 60
)
View Source
const (
	FirstMonitoringBlkHeight        = 1
	UnshieldingBatchTimeoutBlk      = 200
	CheckUnshieldingIntervalSeconds = 30 * 60
)

Variables

View Source
var DefaultNetworkFee = incclient.DefaultPRVFee

Functions

This section is empty.

Types

type AirdropRequest

type AirdropRequest struct {
	PaymentAddress string `json:"paymentaddress"`
}

type AirdropResponse

type AirdropResponse struct {
	Result int `json:"Result"`
}

type BTCBroadcastingManager

type BTCBroadcastingManager struct {
	WorkerAbs
	// contains filtered or unexported fields
}

func (*BTCBroadcastingManager) Execute

func (b *BTCBroadcastingManager) Execute()

This function will execute a worker that has 3 main tasks: - Broadcast a unshielding transaction to Bitcoin network - Check for a Bitcoin transaction is stuck or not and request RBF transaction - Check a broadcasted Bitcoin transaction confirmation and notify the Incognito chain

func (*BTCBroadcastingManager) ExportErrorLog

func (b *BTCBroadcastingManager) ExportErrorLog(msg string)

func (*BTCBroadcastingManager) ExportInfoLog

func (b *BTCBroadcastingManager) ExportInfoLog(msg string)

func (*BTCBroadcastingManager) Init

func (b *BTCBroadcastingManager) Init(
	id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager,
) error

type BTCRelayerV2

type BTCRelayerV2 struct {
	WorkerAbs
	// contains filtered or unexported fields
}

func (*BTCRelayerV2) Execute

func (b *BTCRelayerV2) Execute()

func (*BTCRelayerV2) Init

func (b *BTCRelayerV2) Init(id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager) error

type BTCWalletMonitor

type BTCWalletMonitor struct {
	WorkerAbs
	// contains filtered or unexported fields
}

func (*BTCWalletMonitor) Execute

func (b *BTCWalletMonitor) Execute()

This function will execute a worker that has 2 main tasks: - Monitor Bitcoin multisig wallets that corresponding with Incognito Wallet App users - Send shielding request on behalf of users to Incognito chain

func (*BTCWalletMonitor) ExportErrorLog

func (b *BTCWalletMonitor) ExportErrorLog(msg string)

func (*BTCWalletMonitor) ExportInfoLog

func (b *BTCWalletMonitor) ExportInfoLog(msg string)

func (*BTCWalletMonitor) Init

func (b *BTCWalletMonitor) Init(id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager) error

type BlockchainFeeResponse

type BlockchainFeeResponse struct {
	Result float64
	Error  error
}

type BroadcastTx

type BroadcastTx struct {
	TxContent     string // only has value when be broadcasted
	TxHash        string // only has value when be broadcasted
	VSize         int
	RBFReqTxID    string
	FeePerRequest uint
	NumOfRequests uint
	IsBroadcasted bool
	BlkHeight     uint64 // height of the current Incog chain height when broadcasting tx
}

type BroadcastTxArrayObject

type BroadcastTxArrayObject struct {
	TxArray       map[string]map[string]*BroadcastTx // key: batchID | RBFRexTxID
	NextBlkHeight uint64                             // height of the next block need to scan in Inc chain
}

type ErrorInfo

type ErrorInfo struct {
	Code int    `json:"Code"`
	Msg  string `json:"Msg"`
}

type PortalAddressInstance

type PortalAddressInstance struct {
	IncAddress string `json:"incaddress"`
	BTCAddress string `json:"btcaddress"`
	TimeStamp  int64  `json:"timestamp"`
}

type PortalBackendRes

type PortalBackendRes struct {
	Result []*PortalAddressInstance
	Error  interface{}
}

type RelayingAlerter

type RelayingAlerter struct {
	WorkerAbs
	// contains filtered or unexported fields
}

func (*RelayingAlerter) Execute

func (b *RelayingAlerter) Execute()

func (*RelayingAlerter) Init

func (b *RelayingAlerter) Init(id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager) error

type ShieldingMonitoringInfo

type ShieldingMonitoringInfo struct {
	IncAddress  string
	BTCAddress  string
	TimeStamp   int64
	ScannedTxID map[string]int64
}

type ShieldingRequestInfo

type ShieldingRequestInfo struct {
	TxHash         string
	IncAddress     string
	Proof          string
	BTCBlockHeight uint64
}

type ShieldingTxArrayObject

type ShieldingTxArrayObject struct {
	ShieldingMonitoringList   []*ShieldingMonitoringInfo
	WaitingShieldingList      map[string]*ShieldingRequestInfo // key: proofHash
	LastTimeStampUpdated      int64
	LastScannedBTCBlockHeight int64
}

type UnshieldingAlerter

type UnshieldingAlerter struct {
	WorkerAbs
}

func (*UnshieldingAlerter) Execute

func (b *UnshieldingAlerter) Execute()

func (*UnshieldingAlerter) Init

func (b *UnshieldingAlerter) Init(id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager) error

type Worker

type Worker interface {
	Init(id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager) error
	Execute()
	ExportErrorLog(msg string)
	ExportInfoLog(msg string)
	GetID() int
	GetName() string
	GetFrequency() int
	GetQuitChan() chan bool
	GetNetwork() string
}

type WorkerAbs

type WorkerAbs struct {
	ID                    int
	Name                  string
	Frequency             int // in sec
	Quit                  chan bool
	RPCClient             *utils.HttpClient
	RPCBTCRelayingReaders []*utils.HttpClient
	Network               string // mainnet, testnet, ...
	UTXOManager           *utxomanager.UTXOManager
	Logger                *logrus.Entry
}

func (*WorkerAbs) Execute

func (a *WorkerAbs) Execute()

func (*WorkerAbs) ExportErrorLog

func (a *WorkerAbs) ExportErrorLog(msg string)

func (*WorkerAbs) ExportInfoLog

func (a *WorkerAbs) ExportInfoLog(msg string)

func (*WorkerAbs) GetFrequency

func (a *WorkerAbs) GetFrequency() int

func (*WorkerAbs) GetID

func (a *WorkerAbs) GetID() int

func (*WorkerAbs) GetName

func (a *WorkerAbs) GetName() string

func (*WorkerAbs) GetNetwork

func (a *WorkerAbs) GetNetwork() string

func (*WorkerAbs) GetQuitChan

func (a *WorkerAbs) GetQuitChan() chan bool

func (*WorkerAbs) Init

func (a *WorkerAbs) Init(id int, name string, freq int, network string, utxoManager *utxomanager.UTXOManager) error

Jump to

Keyboard shortcuts

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