data

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: CC0-1.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	APIKey common.Hash `json:"apiKey"`
}

APIKey - Payload to be sent in POST request when either enabling or disabling state of API Key

type ActiveSubscriptions added in v1.8.0

type ActiveSubscriptions struct {
	Count uint64
}

ActiveSubscriptions - Keeps track of how many active websocket connections being maintained now by `ette`

func (*ActiveSubscriptions) Decrement added in v1.8.0

func (a *ActiveSubscriptions) Decrement(by uint64)

Decrement - Safely decrement count by `X`

func (*ActiveSubscriptions) Increment added in v1.8.0

func (a *ActiveSubscriptions) Increment(by uint64)

Increment - Safely increment count by `X`

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               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

func (b *Block) MarshalBinary() ([]byte, error)

MarshalBinary - Implementing binary marshalling function, to be invoked by redis before publishing data on channel

func (*Block) MarshalJSON added in v1.7.0

func (b *Block) MarshalJSON() ([]byte, error)

MarshalJSON - Custom JSON encoder

func (*Block) ToJSON

func (b *Block) ToJSON() []byte

ToJSON - Encodes into JSON, to be supplied when queried for block data

type BlockChainNodeConnection

type BlockChainNodeConnection struct {
	RPC       *ethclient.Client
	Websocket *ethclient.Client
}

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

func (*Blocks) ToJSON

func (b *Blocks) ToJSON() []byte

ToJSON - Encoding into JSON, to be invoked when delivering query result to client

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

func (e *Event) MarshalBinary() ([]byte, error)

MarshalBinary - Implementing binary marshalling function, to be invoked by redis before publishing data on channel

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

MarshalJSON - Custom JSON encoder

func (*Event) ToJSON

func (e *Event) ToJSON() []byte

ToJSON - Encoding into JSON

type Events

type Events struct {
	Events []*Event `json:"events"`
}

Events - A collection of event holder, to be delivered to client in this form

func (*Events) ToJSON

func (e *Events) ToJSON() []byte

ToJSON - Encoding to JSON

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
	BlockPublishTopic, TxPublishTopic, EventPublishTopic string
}

RedisInfo - Holds redis related information in this struct, to be used when passing to functions as argument

type ResultStatus added in v1.1.0

type ResultStatus struct {
	Success uint64
	Failure uint64
}

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 SendReceiveCounter added in v1.8.0

type SendReceiveCounter struct {
	Send    uint64
	Receive uint64
}

SendReceiveCounter - Keeps track of how many read & write ops were performed to & from socket during life time of one single websocket connection

func (*SendReceiveCounter) IncrementReceive added in v1.8.0

func (s *SendReceiveCounter) IncrementReceive(by uint64)

IncrementReceive - To be invoked when new data read from socket

func (*SendReceiveCounter) IncrementSend added in v1.8.0

func (s *SendReceiveCounter) IncrementSend(by uint64)

IncrementSend -To be invoked when new data written into socket

type StatusHolder added in v1.2.0

type StatusHolder struct {
	State *SyncState
	Mutex *sync.RWMutex
}

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) MaxBlockNumberAtStartUp added in v1.5.1

func (s *StatusHolder) MaxBlockNumberAtStartUp() uint64

MaxBlockNumberAtStartUp - Attempting to safely read latest block number when `ette` was started, will help us in deciding whether a missing block related notification needs to be sent on a pubsub channel or not

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
	MaxBlockNumberAtStartUp uint64
	NewBlocksInserted       uint64
	LatestBlockNumber       uint64
}

SyncState - Whether `ette` is synced with blockchain or not

func (*SyncState) BlockCountInDB

func (s *SyncState) BlockCountInDB() uint64

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

Jump to

Keyboard shortcuts

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