scan

package
v0.0.0-...-11d313d Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfSolnIsValid

func CheckIfSolnIsValid(channelID, soln [32]byte, tos TickOrStop) (tf bool)

func IsAddressContract

func IsAddressContract(h *EHub, data []byte)

func IsCatchUpTopic

func IsCatchUpTopic(topic string) (tf bool)

func OpenChannelSim

func OpenChannelSim(inputs []string, value uint64) (nyup NYUP)

func RegisterNodeIDSim

func RegisterNodeIDSim(inputs []string, value uint64) (nyup NYUP)

func RunScannerHubTestTriggersServer

func RunScannerHubTestTriggersServer(e *EHub)

func TxShouldBeValidSansAcctBalance

func TxShouldBeValidSansAcctBalance(methodSig,
	msgSender string, inputs []string, value uint64) (nyup NYUP)

func UnregisterNodeIDSim

func UnregisterNodeIDSim(inputs []string,
	msgSender string, value uint64) (nyup NYUP)

func UpdateNodeIDSim

func UpdateNodeIDSim(inputs []string,
	msgSender string, value uint64) (nyup NYUP)

Types

type BNSH

func (*BNSH) Handle

func (b *BNSH) Handle(h interface{}, message []byte) (er error)

type BlockNumber2LogData

type BlockNumber2LogData struct {
	sync.RWMutex
	M         map[string]*LogData
	BlocksDLL *DoublyLinkedList // for efficient cleanup
}

func (*BlockNumber2LogData) AddData

func (b *BlockNumber2LogData) AddData(blockNumber string, logData []byte)

func (*BlockNumber2LogData) DeleteDataUpTo

func (b *BlockNumber2LogData) DeleteDataUpTo(nAgo uint64)

type BlockNumberScannerHandler

type BlockNumberScannerHandler struct{}

BNSH start

type ChannelID2Info

type ChannelID2Info struct {
	sync.RWMutex
	M    map[string]*ChannelInfo
	SHub *EHub // parent
	// contains filtered or unexported fields
}

func (*ChannelID2Info) IsChannelViable

func (c *ChannelID2Info) IsChannelViable(channelID string,
	tos TickOrStop) (nyup NYUP)

func (*ChannelID2Info) TouchChannel

func (c *ChannelID2Info) TouchChannel(channelID string, nyup NYUP, up *encodings.UnpackedTx)

func (*ChannelID2Info) TouchChannelData

func (c *ChannelID2Info) TouchChannelData(up *encodings.UnpackedTx)

func (*ChannelID2Info) TouchChannelTick

func (c *ChannelID2Info) TouchChannelTick(cd *ChannelData, numTicks uint64)

type ChannelID2Soln

type ChannelID2Soln struct {
	sync.RWMutex
	M    map[string]*Soln
	SHub *EHub // parent
	// contains filtered or unexported fields
}

func (*ChannelID2Soln) AddData

func (s *ChannelID2Soln) AddData(is *RedeemSolutionInput) (numSolns uint64)

func (*ChannelID2Soln) Dump

func (s *ChannelID2Soln) Dump() (pairs []*RedeemSolutionInput)

func (*ChannelID2Soln) SolnIsSubmitted

func (s *ChannelID2Soln) SolnIsSubmitted(channelID, soln string) (tf bool)

func (*ChannelID2Soln) UpdateCache

func (s *ChannelID2Soln) UpdateCache()

type ChannelInfo

type ChannelInfo struct {
	sync.RWMutex
	Address    string
	IsOpenTick NYUP
	IsOpenStop NYUP
	Value      uint64
	Gas        uint64
	GasPrice   uint64
	Ticks      uint64
}

func (*ChannelInfo) IsOpen

func (c *ChannelInfo) IsOpen(tos TickOrStop) (r NYUP)

func (*ChannelInfo) RemainingTOS

func (c *ChannelInfo) RemainingTOS(tos TickOrStop) (r NYUP)

func (*ChannelInfo) SetIsOpen

func (c *ChannelInfo) SetIsOpen(nyup NYUP, tos TickOrStop)

func (*ChannelInfo) SetIsOpenByPrecedence

func (c *ChannelInfo) SetIsOpenByPrecedence(nyup NYUP,
	tos TickOrStop) (r NYUP)

type DataType

type DataType int
const (
	LogsType DataType = iota
	SubscriptionType
	PendingTxType
)

type EHub

type EHub struct {
	BlockNumber *state.BlockNumber // ptr to the global block number
	TxMgr       *state.TxMgr
	ProfileMgr  *state.ProfileMgr

	Scanners *Topic2Scanner
	Solns    *ChannelID2Soln
	Channels *ChannelID2Info
	// contains filtered or unexported fields
}
var G_Hub *EHub

func NewDefaultScannerHub

func NewDefaultScannerHub() (sh *EHub, er error)

func (*EHub) AddData

func (h *EHub) AddData(method, blockNumber string, up *encodings.UnpackedTx)

func (*EHub) CatchUp

func (h *EHub) CatchUp() (er error)

runs CatchUp on all children (scanners)

func (*EHub) CheckPendingTxsForOverextension

func (h *EHub) CheckPendingTxsForOverextension(address string, balance,
	txValue uint64) (ok bool)

func (*EHub) Init

func (h *EHub) Init(topics []string, lookback uint64) (er error)

func (*EHub) InitChannels

func (h *EHub) InitChannels(lookback uint64, w *sync.WaitGroup)

func (*EHub) InitGlobalParameters

func (h *EHub) InitGlobalParameters(w *sync.WaitGroup) <-chan error

func (*EHub) InitSolns

func (h *EHub) InitSolns(lookback uint64, w *sync.WaitGroup)

func (*EHub) InitTestTriggers

func (e *EHub) InitTestTriggers(w *sync.WaitGroup)

func (*EHub) InitializeBlockNumberScanner

func (h *EHub) InitializeBlockNumberScanner(w *sync.WaitGroup)

Initializes custom scanner that keeps global BlockNumber updated

func (*EHub) InitializeProfileMgr

func (h *EHub) InitializeProfileMgr(lookback uint64, w *sync.WaitGroup)

func (*EHub) InitializeTxMgr

func (h *EHub) InitializeTxMgr(w *sync.WaitGroup)

func (*EHub) Listen

func (h *EHub) Listen() (er error)

func (*EHub) SolnIsSubmitted

func (h *EHub) SolnIsSubmitted(channelID, soln string) (tf bool)

func (*EHub) TopicHashes

func (h *EHub) TopicHashes() []string

getter of topicHashes

func (*EHub) Topics

func (h *EHub) Topics() []string

getter of topics

func (*EHub) UpdateCache

func (h *EHub) UpdateCache() (er error)

type EScanner

type EScanner struct {
	SHub Hub // parent

	BlkN2LogData *BlockNumber2LogData
	// contains filtered or unexported fields
}

func (*EScanner) CatchUp

func (s *EScanner) CatchUp() (er error)

first routine called. scans recent logs for nodeIDs and sends to processor

func (*EScanner) DumpData

func (s *EScanner) DumpData() (ret [][]byte)

func (*EScanner) Init

func (s *EScanner) Init(topic string, lookback uint64) (er error)

func (*EScanner) Listen

func (s *EScanner) Listen() (er error)

listener subscribes w websockets, and sends to processor

func (*EScanner) Process

func (s *EScanner) Process(data interface{}, dt DataType) (er error)

process from other members

func (*EScanner) Topic

func (s *EScanner) Topic() string

func (*EScanner) TopicHash

func (s *EScanner) TopicHash() string

func (*EScanner) UpdateCache

func (s *EScanner) UpdateCache() (er error)

type Hub

type Hub interface {
	Init(topics []string, lookback uint64) error
	// TODO CONSOLIDATE INITIALIZERS
	InitializeBlockNumberScanner(w *sync.WaitGroup)
	InitializeTxMgr(w *sync.WaitGroup)
	InitializeProfileMgr(lookback uint64, w *sync.WaitGroup)
	InitGlobalParameters(w *sync.WaitGroup) <-chan error
	InitChannels(lookback uint64, w *sync.WaitGroup)
	InitSolns(lookback uint64, w *sync.WaitGroup)
	InitTestTriggers(w *sync.WaitGroup)
	Topics() []string
	TopicHashes() []string
	CatchUp() error
	Listen() error
	UpdateCache() error // this is to prune irrelevant entries
	AddData(method, blockNumber string, up *encodings.UnpackedTx)
	SolnIsSubmitted(channelID, soln string) (tf bool)
}

type LH

type LH ListenerHandler

func (*LH) Handle

func (l *LH) Handle(s interface{}, message []byte) (er error)

type LSParams

type LSParams struct {
	Result LSResult `json:"result"`
}

type LSResult

type LSResult struct {
	BlockNumber     string `json:"blockNumber"`
	Data            string `json:"data"`
	TransactionHash string `json:"transactionHash"`
}

type ListenerHandler

type ListenerHandler struct{}

type LogData

type LogData struct {
	Data map[string]bool
}

type LogsSubscription

type LogsSubscription struct {
	Params LSParams `json:"params"`
}

type NPTP

type NPTP struct {
	Result string `json:"result"`
}

type NewHeadsParams

type NewHeadsParams struct {
	Result NewHeadsResult `json:"result"`
}

type NewHeadsResponse

type NewHeadsResponse struct {
	Params NewHeadsParams `json:"params"`
}

type NewHeadsResult

type NewHeadsResult struct {
	Number   string `json:"number"`
	GasLimit string `json:"gasLimit"`
}

type NewPendingTransactionsResponse

type NewPendingTransactionsResponse struct {
	Params NPTP `json:"params"`
}

type PTH

func (*PTH) Handle

func (p *PTH) Handle(s interface{}, message []byte) (er error)

type PendingTransactionsHandler

type PendingTransactionsHandler struct{}

type Scanner

type Scanner interface {
	Topic() string
	TopicHash() string
	Init(topic string, lookback uint64) error
	DumpData() [][]byte
	CatchUp() error
	Listen() error
	Process(data interface{}, t DataType) error
	UpdateCache() error // this is to prune irrelevant entries
}

type Soln

type Soln struct {
	sync.RWMutex // mutex not immediately useful, but may be later
	M            map[string]bool
}

type Topic2Scanner

type Topic2Scanner struct {
	sync.RWMutex
	M map[string]*EScanner
}

Jump to

Keyboard shortcuts

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