Documentation ¶
Index ¶
- type Block
- type BlockChainNodeConnection
- type Blocks
- type Event
- type Events
- type Job
- type RedisInfo
- type ResultStatus
- type StatusHolder
- func (s *StatusHolder) BlockCountInDB() uint64
- func (s *StatusHolder) Done() uint64
- func (s *StatusHolder) ElapsedTime() time.Duration
- func (s *StatusHolder) GetLatestBlockNumber() uint64
- func (s *StatusHolder) IncrementBlocksInserted()
- func (s *StatusHolder) IncrementBlocksProcessed()
- func (s *StatusHolder) MaxBlockNumberAtStartUp() uint64
- func (s *StatusHolder) SetLatestBlockNumber(num uint64)
- func (s *StatusHolder) SetStartedAt()
- type SyncState
- type Transaction
- type Transactions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Hash string `json:"hash" gorm:"column:hash"` Number uint64 `json:"number" gorm:"column:number"` Time uint64 `json:"time" gorm:"column:time"` ParentHash string `json:"parentHash" gorm:"column:parenthash"` Difficulty string `json:"difficulty" gorm:"column:difficulty"` GasUsed uint64 `json:"gasUsed" gorm:"column:gasused"` GasLimit uint64 `json:"gasLimit" gorm:"column:gaslimit"` Nonce string `json:"nonce" gorm:"column:nonce"` Miner string `json:"miner" gorm:"column:miner"` Size float64 `json:"size" gorm:"column:size"` StateRootHash string `json:"stateRootHash" gorm:"column:stateroothash"` UncleHash string `json:"uncleHash" gorm:"column:unclehash"` TransactionRootHash string `json:"txRootHash" gorm:"column:txroothash"` ReceiptRootHash string `json:"receiptRootHash" gorm:"column:receiptroothash"` ExtraData []byte `json:"extraData" gorm:"column:extradata"` }
Block - Block related info to be delivered to client in this format
func (*Block) MarshalBinary ¶
MarshalBinary - Implementing binary marshalling function, to be invoked by redis before publishing data on channel
func (*Block) MarshalJSON ¶
MarshalJSON - Custom JSON encoder
type BlockChainNodeConnection ¶
BlockChainNodeConnection - Holds network connection object for blockchain nodes
Use `RPC` i.e. HTTP based connection, for querying blockchain for data Use `Websocket` for real-time listening of events in blockchain
type Blocks ¶
type Blocks struct {
Blocks []*Block `json:"blocks"`
}
Blocks - A set of blocks to be held, extracted from DB query result also to be supplied to client in JSON encoded form
type Event ¶
type Event struct { Origin string `gorm:"column:origin"` Index uint `gorm:"column:index"` Topics pq.StringArray `gorm:"column:topics;type:text[]"` Data []byte `gorm:"column:data"` TransactionHash string `gorm:"column:txhash"` BlockHash string `gorm:"column:blockhash"` }
Event - Single event entity holder, extracted from db
func (*Event) MarshalBinary ¶
MarshalBinary - Implementing binary marshalling function, to be invoked by redis before publishing data on channel
func (*Event) MarshalJSON ¶
MarshalJSON - Custom JSON encoder
type Events ¶
type Events struct {
Events []*Event `json:"events"`
}
Events - A collection of event holder, to be delivered to client in this form
type Job ¶
type Job struct { Client *ethclient.Client DB *gorm.DB Redis *RedisInfo Block uint64 Status *StatusHolder }
Job - For running a block fetching job
type RedisInfo ¶
type RedisInfo struct { Client *redis.Client BlockPublishTopic, TxPublishTopic, EventPublishTopic string }
RedisInfo
type ResultStatus ¶
ResultStatus
func (ResultStatus) Total ¶
func (r ResultStatus) Total() uint64
Total - Returns total count of operations which were supposed to be performed
To check whether all go routines have sent their status i.e. completed their tasks or not
type StatusHolder ¶
StatusHolder - Keeps track of progress. To be delivered when `/v1/synced` is queried
func (*StatusHolder) BlockCountInDB ¶
func (s *StatusHolder) BlockCountInDB() uint64
BlockCountInDB - thread safe reads currently present blocks in db
func (*StatusHolder) Done ¶
func (s *StatusHolder) Done() uint64
Done - thread safe #-of Blocks processed during uptime i.e. after last time it started
func (*StatusHolder) ElapsedTime ¶
func (s *StatusHolder) ElapsedTime() time.Duration
ElapsedTime - thread safe uptime of the service
func (*StatusHolder) GetLatestBlockNumber ¶
func (s *StatusHolder) GetLatestBlockNumber() uint64
GetLatestBlockNumber - thread safe read latest block number
func (*StatusHolder) IncrementBlocksInserted ¶
func (s *StatusHolder) IncrementBlocksInserted()
IncrementBlocksInserted - thread safe increments number of blocks inserted into DB since start
func (*StatusHolder) IncrementBlocksProcessed ¶
func (s *StatusHolder) IncrementBlocksProcessed()
IncrementBlocksProcessed - thread safe increments number of blocks processed by after it started
func (*StatusHolder) MaxBlockNumberAtStartUp ¶
func (s *StatusHolder) MaxBlockNumberAtStartUp() uint64
MaxBlockNumberAtStartUp - thread safe read latest block number at the time of service start To determine whether a missing block related notification needs to be sent on a pubsub channel or not
func (*StatusHolder) SetLatestBlockNumber ¶
func (s *StatusHolder) SetLatestBlockNumber(num uint64)
SetLatestBlockNumber - thread safe write latest block number
func (*StatusHolder) SetStartedAt ¶
func (s *StatusHolder) SetStartedAt()
SetStartedAt - Sets started at time
type SyncState ¶
type SyncState struct { Done uint64 StartedAt time.Time BlockCountAtStartUp uint64 MaxBlockNumberAtStartUp uint64 NewBlocksInserted uint64 LatestBlockNumber uint64 }
SyncState - Whether the service is synced with blockchain or not
func (*SyncState) BlockCountInDB ¶
BlockCountInDB - Blocks currently present in database
type Transaction ¶
type Transaction struct { Hash string `json:"hash" gorm:"column:hash"` From string `json:"from" gorm:"column:from"` To string `json:"to" gorm:"column:to"` Contract string `json:"contract" gorm:"column:contract"` Value string `json:"value" gorm:"column:value"` Data []byte `json:"data" gorm:"column:data"` Gas uint64 `json:"gas" gorm:"column:gas"` GasPrice string `json:"gasPrice" gorm:"column:gasprice"` Cost string `json:"cost" gorm:"column:cost"` Nonce uint64 `json:"nonce" gorm:"column:nonce"` State uint64 `json:"state" gorm:"column:state"` BlockHash string `json:"blockHash" gorm:"column:blockhash"` }
Transaction - Transaction holder struct, to be supplied when queried using tx hash
func (*Transaction) MarshalBinary ¶
func (t *Transaction) MarshalBinary() ([]byte, error)
MarshalBinary - Implementing binary marshalling function, to be invoked by redis before publishing data on channel
func (*Transaction) MarshalJSON ¶
func (t *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON - Custom JSON encoder
func (*Transaction) ToJSON ¶
func (t *Transaction) ToJSON() []byte
ToJSON - JSON encoder, to be invoked before delivering tx query data to client
type Transactions ¶
type Transactions struct {
Transactions []*Transaction `json:"transactions"`
}
Transactions - Multiple transactions holder struct
func (*Transactions) ToJSON ¶
func (t *Transactions) ToJSON() []byte
ToJSON - Encoding into JSON, to be invoked when delivering to client