Documentation ¶
Index ¶
- type APIKey
- type AuthPayload
- type AuthPayloadMessage
- 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) 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 APIKey ¶
APIKey - Payload to be sent in POST request when either enabling or disabling state of API Key
type AuthPayload ¶
type AuthPayload struct { Message AuthPayloadMessage `json:"message" binding:"required"` Signature string `json:"signature" binding:"required"` }
AuthPayload - Payload to be sent in post request body, when performing login
func (*AuthPayload) HasExpired ¶
func (a *AuthPayload) HasExpired(window int64) bool
HasExpired - Checking if message was signed with in `window` seconds ( will be kept generally 30s ) time span from current server time or not
func (*AuthPayload) IsAdmin ¶
func (a *AuthPayload) IsAdmin(signer []byte) bool
IsAdmin - Given recovered signer address from authentication payload checks whether this address matches with admin address present in `.env` file or not
func (*AuthPayload) RecoverSigner ¶
func (a *AuthPayload) RecoverSigner() []byte
RecoverSigner - Given signed message & original message it recovers signer address as byte array, which is to be later used for matching against claimed signer address
func (*AuthPayload) VerifySignature ¶
func (a *AuthPayload) VerifySignature(signer []byte) bool
VerifySignature - Given recovered signer address from authentication payload checks whether person claiming to sign message has really signed or not
type AuthPayloadMessage ¶
type AuthPayloadMessage struct { Address common.Address `json:"address" binding:"required"` TimeStamp uint64 `json:"timestamp" binding:"required"` }
AuthPayloadMessage - Message to be signed by user
func (*AuthPayloadMessage) ToJSON ¶
func (a *AuthPayloadMessage) ToJSON() []byte
ToJSON - Encoding message to JSON, this is what was signed by user
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 uint64 `json:"nonce" gorm:"column:nonce"` Miner string `json:"miner" gorm:"column:miner"` Size float64 `json:"size" gorm:"column:size"` TransactionRootHash string `json:"txRootHash" gorm:"column:txroothash"` ReceiptRootHash string `json:"receiptRootHash" gorm:"column:receiptroothash"` }
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
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, these are all the information which are required
type RedisInfo ¶ added in v1.2.0
type RedisInfo struct { Client *redis.Client // using this object `ette` will talk to Redis BlockRetryQueueName string // retry queue name, for storing block numbers UnfinalizedBlocksQueueName string // stores unfinalized block numbers, processes }
RedisInfo - Holds redis related information in this struct, to be used when passing to functions as argument
type ResultStatus ¶ added in v1.1.0
ResultStatus - Keeps track of how many operations went successful and how many of them failed
func (ResultStatus) Total ¶ added in v1.1.0
func (r ResultStatus) Total() uint64
Total - Returns total count of operations which were supposed to be performed
To be useful when deciding whether all go routines have sent their status i.e. completed their task or not
type StatusHolder ¶ added in v1.2.0
StatusHolder - Keeps track of progress being made by `ette` over time, which is to be delivered when `/v1/synced` is queried
func (*StatusHolder) BlockCountInDB ¶ added in v1.2.0
func (s *StatusHolder) BlockCountInDB() uint64
BlockCountInDB - Safely reads currently present blocks in database
func (*StatusHolder) Done ¶ added in v1.2.0
func (s *StatusHolder) Done() uint64
Done - #-of Blocks processed during `ette` uptime i.e. after last time it started
func (*StatusHolder) ElapsedTime ¶ added in v1.2.0
func (s *StatusHolder) ElapsedTime() time.Duration
ElapsedTime - Uptime of `ette`
func (*StatusHolder) GetLatestBlockNumber ¶ added in v1.3.0
func (s *StatusHolder) GetLatestBlockNumber() uint64
GetLatestBlockNumber - Attempting to safely read latest block number seen
func (*StatusHolder) IncrementBlocksInserted ¶ added in v1.2.0
func (s *StatusHolder) IncrementBlocksInserted()
IncrementBlocksInserted - Increments number of blocks inserted into DB after `ette` started processing blocks
func (*StatusHolder) IncrementBlocksProcessed ¶ added in v1.2.0
func (s *StatusHolder) IncrementBlocksProcessed()
IncrementBlocksProcessed - Increments number of blocks processed by `ette after it started
func (*StatusHolder) SetLatestBlockNumber ¶ added in v1.3.0
func (s *StatusHolder) SetLatestBlockNumber(num uint64)
SetLatestBlockNumber - Attempting to safely write latest block number
func (*StatusHolder) SetStartedAt ¶ added in v1.2.0
func (s *StatusHolder) SetStartedAt()
SetStartedAt - Sets started at time
type SyncState ¶
type SyncState struct { Done uint64 StartedAt time.Time BlockCountAtStartUp uint64 NewBlocksInserted uint64 LatestBlockNumber uint64 }
SyncState - Whether `ette` 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