Documentation ¶
Index ¶
- func AddNewSubscriptionPlan(_db *gorm.DB, name string, deliveryCount uint64)
- func AddSubscriptionPlanForAddress(_db *gorm.DB, address common.Address, planID uint32) bool
- func ComputeAPIKeyForAddress(_db *gorm.DB, address common.Address) []byte
- func Connect() *gorm.DB
- func CreateSubscriptionPlan(_db *gorm.DB, name string, deliveryCount uint64)
- func DeleteBlock(dbWTx *gorm.DB, number uint64) error
- func DeliveryCountByPlanName(_db *gorm.DB, planName string) (uint64, error)
- func DoesItMatch(event *data.Event, topics map[uint8]string) bool
- func DropOldDeliveryHistories(_db *gorm.DB)
- func EventTopicsAsString(topics map[uint8]string) string
- func ExtractOutOnlyMatchingEvents(events []*data.Event, topics map[uint8]string) *data.Events
- func GetAllBlockNumbersInRange(db *gorm.DB, from uint64, to uint64) []uint64
- func GetAllowedDeliveryCountByAddress(_db *gorm.DB, address common.Address) uint64
- func GetBlockByHash(db *gorm.DB, hash common.Hash) *data.Block
- func GetBlockByNumber(db *gorm.DB, number uint64) *data.Block
- func GetBlockCount(db *gorm.DB) uint64
- func GetBlocksByNumberRange(db *gorm.DB, from uint64, to uint64) *data.Blocks
- func GetBlocksByTimeRange(db *gorm.DB, from uint64, to uint64) *data.Blocks
- func GetContractCreationTransactionsFromAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
- func GetContractCreationTransactionsFromAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
- func GetCurrentBlockNumber(db *gorm.DB) uint64
- func GetCurrentOldestBlockNumber(db *gorm.DB) uint64
- func GetDefaultSubscriptionPlanID(_db *gorm.DB) uint32
- func GetEventByBlockHashAndLogIndex(db *gorm.DB, hash common.Hash, index uint) *data.Event
- func GetEventByBlockNumberAndLogIndex(db *gorm.DB, number uint64, index uint) *data.Event
- func GetEventsByBlockHash(db *gorm.DB, blockHash common.Hash) *data.Events
- func GetEventsByTransactionHash(db *gorm.DB, txHash common.Hash) *data.Events
- func GetEventsFromContractByBlockNumberRange(db *gorm.DB, contract common.Address, from uint64, to uint64) *data.Events
- func GetEventsFromContractByBlockTimeRange(db *gorm.DB, contract common.Address, from uint64, to uint64) *data.Events
- func GetEventsFromContractWithTopicsByBlockNumberRange(db *gorm.DB, contract common.Address, from uint64, to uint64, ...) *data.Events
- func GetEventsFromContractWithTopicsByBlockTimeRange(db *gorm.DB, contract common.Address, from uint64, to uint64, ...) *data.Events
- func GetLastXEventsFromContract(db *gorm.DB, contract common.Address, x int) *data.Events
- func GetTransactionByHash(db *gorm.DB, hash common.Hash) *data.Transaction
- func GetTransactionCountBetweenAccountsByBlockNumberRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, ...) int64
- func GetTransactionCountBetweenAccountsByBlockTimeRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, ...) int64
- func GetTransactionCountByBlockHash(db *gorm.DB, hash common.Hash) int64
- func GetTransactionCountByBlockNumber(db *gorm.DB, number uint64) int64
- func GetTransactionCountFromAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
- func GetTransactionCountFromAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
- func GetTransactionCountToAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
- func GetTransactionCountToAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
- func GetTransactionFromAccountWithNonce(db *gorm.DB, account common.Address, nonce uint64) *data.Transaction
- func GetTransactionsBetweenAccountsByBlockNumberRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, ...) *data.Transactions
- func GetTransactionsBetweenAccountsByBlockTimeRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, ...) *data.Transactions
- func GetTransactionsByBlockHash(db *gorm.DB, hash common.Hash) *data.Transactions
- func GetTransactionsByBlockNumber(db *gorm.DB, number uint64) *data.Transactions
- func GetTransactionsFromAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
- func GetTransactionsFromAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
- func GetTransactionsToAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
- func GetTransactionsToAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
- func IsUnderRateLimit(_db *gorm.DB, userAddress string) bool
- func IsValidSubscriptionPlan(_db *gorm.DB, id uint32) bool
- func PersistAllSubscriptionPlans(_db *gorm.DB, file string)
- func PutBlock(dbWTx *gorm.DB, block *Blocks) error
- func PutDataDeliveryInfo(_db *gorm.DB, client string, endPoint string, dataLength uint64)
- func RegisterNewApp(_db *gorm.DB, address common.Address) bool
- func RemoveEventsByBlockHash(dbWTx *gorm.DB, blockHash string) error
- func RemoveTransactionsByBlockHash(dbWTx *gorm.DB, blockHash string) error
- func StoreBlock(dbWOTx *gorm.DB, block *PackedBlock, status *d.StatusHolder, ...) error
- func ToggleAPIKeyState(_db *gorm.DB, apiKey string) bool
- func UpdateBlock(dbWTx *gorm.DB, block *Blocks) error
- func UpdateSubscriptionPlan(_db *gorm.DB, name string, deliveryCount uint64)
- func UpsertEvent(dbWTx *gorm.DB, event *Events) error
- func UpsertTransaction(dbWTx *gorm.DB, tx *Transactions) error
- func ValidateAPIKey(_db *gorm.DB, apiKey string) bool
- type Blocks
- type DeliveryHistory
- type Events
- type PackedBlock
- type PackedTransaction
- type SubscriptionDetails
- type SubscriptionPlans
- type Tabler
- type Transactions
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNewSubscriptionPlan ¶
AddNewSubscriptionPlan - Adding new subcription plan to database after those being read from .plans.json
Taking into consideration the factor, whether it has been already persisted or not, or any changes made to `.plans.json` file
func AddSubscriptionPlanForAddress ¶
AddSubscriptionPlanForAddress - Persisting subscription plan for one ethereum address, when this address is first time creating one `ette` application
func ComputeAPIKeyForAddress ¶
ComputeAPIKeyForAddress - Computing new API key for user address, by taking `nonce` of that account & current unix time stamp ( with nanosecond level precision )
under consideration
Here `nonce` is nothing but count of applications created in `ette` by account ¶
`Time` field is being added when computing next API key for making it more unpredictable
Previous implementation had very predicatable pattern
func CreateSubscriptionPlan ¶ added in v1.2.0
CreateSubscriptionPlan - Creates new entry for subscription plan
func DeleteBlock ¶ added in v1.10.0
DeleteBlock - Delete block entry, identified by block number, while cascading all dependent entries ( i.e. in transactions/ events table )
func DeliveryCountByPlanName ¶ added in v1.2.0
DeliveryCountByPlanName - Given subscription plan name, returns subscription plan's delivery count
func DoesItMatch ¶ added in v1.7.0
DoesItMatch - Given one event emitted by some contract & topic signature against which we're attempting to match the event it'll return boolean depending upon whether it's satisfying all conditions or not
func DropOldDeliveryHistories ¶ added in v1.8.0
DropOldDeliveryHistories - Attempts to delete older than 24 hours delivery history from data store, because that piece of data is not being used any where, so no need to keep it
Before delivering any piece of data to client, rate limit to be checked for last 24 hours not older than that
@note This function can be invoked every 24 hours to clean up historical entries
func EventTopicsAsString ¶ added in v1.7.0
EventTopicsAsString - Given event topic signatures as map, returns these topics as string, seperated by `,` i.e. comma to be used for forming DB raw query
func ExtractOutOnlyMatchingEvents ¶ added in v1.7.0
ExtractOutOnlyMatchingEvents - Extract out only those events which are having full match with specified event topic signatures
func GetAllBlockNumbersInRange ¶ added in v1.5.0
GetAllBlockNumbersInRange - Returns all block numbers in given range, both inclusive
func GetAllowedDeliveryCountByAddress ¶ added in v1.3.0
GetAllowedDeliveryCountByAddress - Returns how many deliveries can be made to user in 24 hours, as per plan they're subscribed to
func GetBlockByHash ¶
GetBlockByHash - Given blockhash finds out block related information
If not found, returns nil
func GetBlockCount ¶
GetBlockCount - Returns how many blocks currently present in database
Caution : As we're dealing with very large tables ( with row count ~ 10M & increasing 1 row every 2 seconds ) this function needs to be least frequently, otherwise due to full table scan it'll cost us a lot
Currently only using during application start up ¶
All other block count calculation requirements can be fulfilled by using in-memory program state holder
func GetBlocksByNumberRange ¶
GetBlocksByNumberRange - Given block numbers as range, it'll extract out those blocks by number, while returning them in ascendically sorted form in terms of block numbers
Note : Can return at max 10 blocks in a single query
If more blocks are requested, simply to be rejected In that case, consider splitting them such that they satisfy criteria
func GetBlocksByTimeRange ¶
GetBlocksByTimeRange - Given time range ( of 60 sec span at max ), returns blocks mined in that time span
If asked to find out blocks in time span larger than 60 sec, simply drops query request
func GetContractCreationTransactionsFromAccountByBlockNumberRange ¶
func GetContractCreationTransactionsFromAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
GetContractCreationTransactionsFromAccountByBlockNumberRange - Fetch all contract creation tx(s) from given account with in specific block number range
func GetContractCreationTransactionsFromAccountByBlockTimeRange ¶
func GetContractCreationTransactionsFromAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
GetContractCreationTransactionsFromAccountByBlockTimeRange - Fetch all contract creation tx(s) from given account with in specific block time span range
func GetCurrentBlockNumber ¶
GetCurrentBlockNumber - Returns highest block number, which got processed by `ette`
func GetCurrentOldestBlockNumber ¶
GetCurrentOldestBlockNumber - Fetches what's lowest block number present in database, which denotes if it's not 0, from here we can start syncing again, until we reach 0
func GetDefaultSubscriptionPlanID ¶
GetDefaultSubscriptionPlanID - Finding out that subscription plan id, which has lowest daily deliveryCount promise, which is going to be always default plan, when a new ethereum address joins `ette`
func GetEventByBlockHashAndLogIndex ¶ added in v1.4.0
GetEventByBlockHashAndLogIndex - Given block hash and log index in block return respective event log, if any exists
func GetEventByBlockNumberAndLogIndex ¶ added in v1.4.0
GetEventByBlockNumberAndLogIndex - Given block number and log index in block return respective event log, if any exists
func GetEventsByBlockHash ¶
GetEventsByBlockHash - Given block hash retrieves all events from all tx present in that block
func GetEventsByTransactionHash ¶
GetEventsByTransactionHash - Given tx hash, returns all events emitted during contract interaction ( i.e. tx execution )
func GetEventsFromContractByBlockNumberRange ¶
func GetEventsFromContractByBlockNumberRange(db *gorm.DB, contract common.Address, from uint64, to uint64) *data.Events
GetEventsFromContractByBlockNumberRange - Given block number range & contract address, extracts out all events emitted by this contract during block span
func GetEventsFromContractByBlockTimeRange ¶
func GetEventsFromContractByBlockTimeRange(db *gorm.DB, contract common.Address, from uint64, to uint64) *data.Events
GetEventsFromContractByBlockTimeRange - Given block time range & contract address, extracts out all events emitted by this contract during time span
func GetEventsFromContractWithTopicsByBlockNumberRange ¶
func GetEventsFromContractWithTopicsByBlockNumberRange(db *gorm.DB, contract common.Address, from uint64, to uint64, topics map[uint8]string) *data.Events
GetEventsFromContractWithTopicsByBlockNumberRange - Given block number range, contract address & topics of event log, extracts out all events emitted by this contract during block span with topic signatures matching
func GetEventsFromContractWithTopicsByBlockTimeRange ¶
func GetEventsFromContractWithTopicsByBlockTimeRange(db *gorm.DB, contract common.Address, from uint64, to uint64, topics map[uint8]string) *data.Events
GetEventsFromContractWithTopicsByBlockTimeRange - Given time range, contract address & topics of event log, extracts out all events emitted by this contract during block span with topic signatures matching
func GetLastXEventsFromContract ¶
GetLastXEventsFromContract - Finds out last `x` events emitted by contract
func GetTransactionByHash ¶
GetTransactionByHash - Given tx hash, extracts out transaction related data
func GetTransactionCountBetweenAccountsByBlockNumberRange ¶ added in v1.8.0
func GetTransactionCountBetweenAccountsByBlockNumberRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, to uint64) int64
GetTransactionCountBetweenAccountsByBlockNumberRange - Given from & to account addresses & block number range, returns #-of transactions where `from` & `to` fields are matching
func GetTransactionCountBetweenAccountsByBlockTimeRange ¶ added in v1.8.0
func GetTransactionCountBetweenAccountsByBlockTimeRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, to uint64) int64
GetTransactionCountBetweenAccountsByBlockTimeRange - Given from & to account addresses & block mining time range, returns #-of transactions where `from` & `to` fields are matching
func GetTransactionCountByBlockHash ¶ added in v1.8.0
GetTransactionCountByBlockHash - Given block hash, finds out how many transactions are packed in that block
func GetTransactionCountByBlockNumber ¶ added in v1.8.0
GetTransactionCountByBlockNumber - Given block number, finds out how many transactions are packed in that block
func GetTransactionCountFromAccountByBlockNumberRange ¶ added in v1.8.0
func GetTransactionCountFromAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
GetTransactionCountFromAccountByBlockNumberRange - Given account address & block number range, it can find out how many tx(s) were sent from this account in specified block range
func GetTransactionCountFromAccountByBlockTimeRange ¶ added in v1.8.0
func GetTransactionCountFromAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
GetTransactionCountFromAccountByBlockTimeRange - Given account address & block mining time stamp range, it can find out count of all tx(s) performed by this address, with in that time span
func GetTransactionCountToAccountByBlockNumberRange ¶ added in v1.8.0
func GetTransactionCountToAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
GetTransactionCountToAccountByBlockNumberRange - Given account address & block number range, returns #-of transactions where `account` was in `to` field
func GetTransactionCountToAccountByBlockTimeRange ¶ added in v1.8.0
func GetTransactionCountToAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) int64
GetTransactionCountToAccountByBlockTimeRange - Given account address which is present in `to` field of tx(s) held in blocks mined with in given time range, returns those tx count
func GetTransactionFromAccountWithNonce ¶
func GetTransactionFromAccountWithNonce(db *gorm.DB, account common.Address, nonce uint64) *data.Transaction
GetTransactionFromAccountWithNonce - Given tx sender address & account nonce, finds out tx, satisfying condition
func GetTransactionsBetweenAccountsByBlockNumberRange ¶
func GetTransactionsBetweenAccountsByBlockNumberRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, to uint64) *data.Transactions
GetTransactionsBetweenAccountsByBlockNumberRange - Given from & to account addresses & block number range, returns transactions where `from` & `to` fields are matching
func GetTransactionsBetweenAccountsByBlockTimeRange ¶
func GetTransactionsBetweenAccountsByBlockTimeRange(db *gorm.DB, fromAccount common.Address, toAccount common.Address, from uint64, to uint64) *data.Transactions
GetTransactionsBetweenAccountsByBlockTimeRange - Given from & to account addresses & block mining time range, returns transactions where `from` & `to` fields are matching
func GetTransactionsByBlockHash ¶
GetTransactionsByBlockHash - Given block hash, returns all transactions present in that block
func GetTransactionsByBlockNumber ¶
func GetTransactionsByBlockNumber(db *gorm.DB, number uint64) *data.Transactions
GetTransactionsByBlockNumber - Given block number, returns all transactions present in that block
func GetTransactionsFromAccountByBlockNumberRange ¶
func GetTransactionsFromAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
GetTransactionsFromAccountByBlockNumberRange - Given account address & block number range, it can find out all transactions which are performed from this account
func GetTransactionsFromAccountByBlockTimeRange ¶
func GetTransactionsFromAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
GetTransactionsFromAccountByBlockTimeRange - Given account address & block mining time stamp range, it can find out all tx(s) performed from this account, with in that time span
func GetTransactionsToAccountByBlockNumberRange ¶
func GetTransactionsToAccountByBlockNumberRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
GetTransactionsToAccountByBlockNumberRange - Given account address & block number range, returns transactions where `account` was in `to` field
func GetTransactionsToAccountByBlockTimeRange ¶
func GetTransactionsToAccountByBlockTimeRange(db *gorm.DB, account common.Address, from uint64, to uint64) *data.Transactions
GetTransactionsToAccountByBlockTimeRange - Given account address which is present in `to` field of tx(s) held in blocks mined with in given time range
func IsUnderRateLimit ¶
IsUnderRateLimit - Checks whether number of times data delivered to client application on this day ( identified using signer address i.e. who created API Key ), for query response or for real-time data delivery, is under a limit ( currently hardcoded inside code ) or not
func IsValidSubscriptionPlan ¶
IsValidSubscriptionPlan - Given subscription plan id, checking against database whether it's a valid one or not
func PersistAllSubscriptionPlans ¶
PersistAllSubscriptionPlans - Given path to user created subscription plan holder “.plans.json` file, it'll read that content into memory & then parse JSON content of its, which will be persisted into database, into `subscription_plans` table
func PutDataDeliveryInfo ¶
PutDataDeliveryInfo - Persisting data delivery info, before it's sent to client application
dataLength is length of data in bytes, sent to client application
func RegisterNewApp ¶
RegisterNewApp - Registering new application for given address
func RemoveEventsByBlockHash ¶ added in v1.7.0
RemoveEventsByBlockHash - All events emitted by tx(s) packed in block, to be removed from DB
func RemoveTransactionsByBlockHash ¶ added in v1.7.0
RemoveTransactionsByBlockHash - Remove all tx(s) packed in this block from DB
func StoreBlock ¶
func StoreBlock(dbWOTx *gorm.DB, block *PackedBlock, status *d.StatusHolder, queue *q.BlockProcessorQueue) error
StoreBlock - Persisting block data in database, if data already not stored
Also checks equality with existing data, if mismatch found, updated with latest data
Tries to wrap db modifications inside database transaction to guarantee consistency, other read only operations being performed without protection of db transaction
👆 gives us performance improvement, also taste of atomic db operation i.e. either whole block data is written or nothing is written
func ToggleAPIKeyState ¶
ToggleAPIKeyState - Given valid API key, toggles its enabled state
func UpdateBlock ¶
UpdateBlock - Updating already existing block
func UpdateSubscriptionPlan ¶ added in v1.2.0
UpdateSubscriptionPlan - Tries to update existing subscription plan, where it's assumed plan name is unchanged & allowed delivery count in 24 hours has got updated
func UpsertEvent ¶ added in v1.3.0
UpsertEvent - It may be the case previously this block was processed and event log also got persisted into database, which has been updated on chain, due to chain reorganization
Now we want to persist latest entry into database, using upsert operation i.e. if entry doesn't exist yet, it'll be created, but if it does i.e. conflicting primary key found, then, all fields will be updated to latest value
func UpsertTransaction ¶ added in v1.3.0
func UpsertTransaction(dbWTx *gorm.DB, tx *Transactions) error
UpsertTransaction - It may be the case previously this block was processed and transaction also got persisted into database, which has been updated on chain, due to chain reorganization
Now we want to persist latest entry into database, using upsert operation i.e. if entry doesn't exist yet, it'll be created, but if it does i.e. conflicting primary key found, then, all fields will be updated to latest value
Types ¶
type Blocks ¶
type Blocks struct { Hash string `gorm:"column:hash;type:char(66);primaryKey"` Number uint64 `gorm:"column:number;type:bigint;not null;unique;index:,sort:asc"` Time uint64 `gorm:"column:time;type:bigint;not null;index:,sort:asc"` ParentHash string `gorm:"column:parenthash;type:char(66);not null"` Difficulty string `gorm:"column:difficulty;type:varchar;not null"` GasUsed uint64 `gorm:"column:gasused;type:bigint;not null"` GasLimit uint64 `gorm:"column:gaslimit;type:bigint;not null"` Nonce string `gorm:"column:nonce;type:varchar;not null"` Miner string `gorm:"column:miner;type:char(42);not null"` Size float64 `gorm:"column:size;type:float(8);not null"` StateRootHash string `gorm:"column:stateroothash;type:char(66);not null"` UncleHash string `gorm:"column:unclehash;type:char(66);not null"` TransactionRootHash string `gorm:"column:txroothash;type:char(66);not null"` ReceiptRootHash string `gorm:"column:receiptroothash;type:char(66);not null"` ExtraData []byte `gorm:"column:extradata;type:bytea"` Transactions Transactions `gorm:"foreignKey:blockhash;constraint:OnDelete:CASCADE;"` Events Events `gorm:"foreignKey:blockhash;constraint:OnDelete:CASCADE;"` }
Blocks - Mined block info holder table model
type DeliveryHistory ¶
type DeliveryHistory struct { ID string `gorm:"column:id;type:uuid;default:gen_random_uuid();primaryKey"` Client string `gorm:"column:client;type:char(42);not null;index"` TimeStamp time.Time `gorm:"column:ts;type:timestamp;not null;index:,sort:asc"` EndPoint string `gorm:"column:endpoint;type:varchar(100);not null"` DataLength uint64 `gorm:"column:datalength;type:bigint;not null"` }
DeliveryHistory - For each request coming from client application we're keeping track of how much data gets sent back in response of their query
This is to be used for controlling client application's access to resources they're requesting
func (DeliveryHistory) TableName ¶
func (DeliveryHistory) TableName() string
TableName - Overriding default table name
type Events ¶
type Events struct { BlockHash string `gorm:"column:blockhash;type:char(66);not null;primaryKey"` Index uint `gorm:"column:index;type:integer;not null;primaryKey"` Origin string `gorm:"column:origin;type:char(42);not null;index"` Topics pq.StringArray `gorm:"column:topics;type:text[];not null;index:,type:gin"` Data []byte `gorm:"column:data;type:bytea"` TransactionHash string `gorm:"column:txhash;type:char(66);not null;index"` }
Events - Events emitted from smart contracts to be held in this table
type PackedBlock ¶ added in v1.2.0
type PackedBlock struct { Block *Blocks Transactions []*PackedTransaction }
PackedBlock - Whole block data to be persisted in a single database transaction to ensure data consistency, if something goes wrong in mid, whole persisting operation will get reverted
type PackedTransaction ¶ added in v1.2.0
type PackedTransaction struct { Tx *Transactions Events []*Events }
PackedTransaction - All data that is stored in a tx, to be passed from tx data fetcher to whole block data persist handler function
type SubscriptionDetails ¶
type SubscriptionDetails struct { Address string `gorm:"column:address;type:char(42);primaryKey" json:"address"` SubscriptionPlan uint32 `gorm:"column:subscriptionplan;type:int;not null;index" json:"subscriptionPlan"` }
SubscriptionDetails - Keeps track of which ethereum address has subscription to which plan where, `subscriptionplan` refers to `id` in subscription_plans table and `address` refers to address in users table
func CheckSubscriptionPlanByAddress ¶
func CheckSubscriptionPlanByAddress(_db *gorm.DB, address common.Address) *SubscriptionDetails
CheckSubscriptionPlanByAddress - Given user's ethereum address, checking if user has already subscribed to any plan or not
func (SubscriptionDetails) TableName ¶
func (SubscriptionDetails) TableName() string
TableName - Overriding default table name
type SubscriptionPlans ¶
type SubscriptionPlans struct { ID uint32 `gorm:"column:id;type:serial;primaryKey" json:"id"` Name string `gorm:"column:name;type:varchar(20);not null;unique" json:"name"` DeliveryCount uint64 `gorm:"column:deliverycount;type:bigint;not null;unique" json:"deliveryCount"` SubscriptionDetails SubscriptionDetails `gorm:"foreignKey:subscriptionplan"` }
SubscriptionPlans - Allowed subscription plans, to be auto populated from .plans.json, at application start up
func CheckSubscriptionPlanDetailsByAddress ¶
func CheckSubscriptionPlanDetailsByAddress(_db *gorm.DB, address common.Address) *SubscriptionPlans
CheckSubscriptionPlanDetailsByAddress - Given address of subscriber, returns full plan details to which they're subscribed
func GetAllSubscriptionPlans ¶
func GetAllSubscriptionPlans(_db *gorm.DB) []*SubscriptionPlans
GetAllSubscriptionPlans - Returns a list of all available susbcription plans from this `ette` instance
func (SubscriptionPlans) TableName ¶
func (SubscriptionPlans) TableName() string
TableName - Overriding default table name
type Transactions ¶
type Transactions struct { Hash string `gorm:"column:hash;type:char(66);primaryKey"` From string `gorm:"column:from;type:char(42);not null;index"` To string `gorm:"column:to;type:char(42);index"` Contract string `gorm:"column:contract;type:char(42);index"` Value string `gorm:"column:value;type:varchar"` Data []byte `gorm:"column:data;type:bytea"` Gas uint64 `gorm:"column:gas;type:bigint;not null"` GasPrice string `gorm:"column:gasprice;type:varchar;not null"` Cost string `gorm:"column:cost;type:varchar;not null"` Nonce uint64 `gorm:"column:nonce;type:bigint;not null;index"` State uint64 `gorm:"column:state;type:smallint;not null"` BlockHash string `gorm:"column:blockhash;type:char(66);not null;index"` Events Events `gorm:"foreignKey:txhash;constraint:OnDelete:CASCADE;"` }
Transactions - Blockchain transaction holder table model
func (Transactions) TableName ¶
func (Transactions) TableName() string
TableName - Overriding default table name
type Users ¶
type Users struct { Address string `gorm:"column:address;type:char(42);not null;index" json:"address"` APIKey string `gorm:"column:apikey;type:char(66);primaryKey" json:"apiKey"` TimeStamp time.Time `gorm:"column:ts;type:timestamp;not null" json:"timeStamp"` Enabled bool `gorm:"column:enabled;type:boolean;default:true" json:"enabled"` }
Users - User address & created api key related info, holder table
func GetAppsByUserAddress ¶
GetAppsByUserAddress - Given user address, returns list of all apps created by user, along with their API key & respective creation timestamp
func GetUserFromAPIKey ¶
GetUserFromAPIKey - Given API Key, tries to find out if there's any user registered who signed for creating this API Key