Documentation ¶
Overview ¶
Package blockshot provides functions for iterating over the Celo blockchain block-by-block to perform a list of extraction tasks over each block.
Index ¶
- Variables
- func BlockIterator(db *sql.DB, tasks []Task)
- func CreateCommissionsSnapshotDataTable(db *sql.DB)
- func CreateEventLogsTable(db *sql.DB)
- func CreateRewardsSnapshotDataTable(db *sql.DB)
- func CreateSnapshotBlocksTable(db *sql.DB)
- func CreateSnapshotDataTable(db *sql.DB)
- func CreateStatusTable(db *sql.DB)
- func CreateSystemSnapshotDataTable(db *sql.DB)
- func CreateTagsTable(db *sql.DB)
- func CreateTransactionsTable(db *sql.DB)
- func CreateVotesSnapshotDataTable(db *sql.DB)
- func DBExec(statement string, db *sql.DB)
- func DeleteTable(tableName string, db *sql.DB)
- func DumpEventLog(db *sql.DB, blockNumber *big.Int, eLog *EventLog)
- func DumpTagsRow(db *sql.DB, blockNumber *big.Int, txHash string, from string, to string, ...)
- func DumpTransaction(db *sql.DB, blockNumber *big.Int, timestamp string, txHash string, ...)
- func GenerateTransactionTags(db *sql.DB, blockNumber *big.Int) error
- func GetHashOfTransactions(db *sql.DB, blockNumber *big.Int) ([]string, error)
- func InitClients()
- func LatestIteratedBlockNumber(db *sql.DB) *big.Int
- func ProcessEventLogs(db *sql.DB, blockNumber *big.Int) error
- func ProcessTransactions(db *sql.DB, blockNumber *big.Int) error
- func ResetDatabase(db *sql.DB)
- func SetIterationStatusComplete(db *sql.DB, blockNumber *big.Int)
- func TakeDailySnapshots(db *sql.DB, blockNumber *big.Int) error
- func TopicHashHex(signature string) string
- type EventLog
- type EventLogs
- type LogAccountSlashed
- type LogApproval
- type LogGoldLocked
- type LogGoldRelocked
- type LogGoldUnlocked
- type LogGoldWithdrawn
- type LogGovernanceSlashPerformed
- type LogProposalDequeued
- type LogProposalQueued
- type LogProposalUpvoteRevoked
- type LogProposalUpvoted
- type LogProposalVoted
- type LogSlashingApproved
- type LogTransfer
- type LogTransferComment
- type LogValidatorGroupActiveVoteRevoked
- type LogValidatorGroupPendingVoteRevoked
- type LogValidatorGroupVoteActivated
- type LogValidatorGroupVoteCast
- type Tag
- type Tags
- type Task
- type Transaction
- type TransactionDetailed
Constants ¶
This section is empty.
Variables ¶
var ( //DowntimeSlasher.sol DowntimeSlashPerformedHash = TopicHashHex("DowntimeSlashPerformed(address,uint256)") ValidatorGroupMarkedEligibleHash = TopicHashHex("ValidatorGroupMarkedEligible(address)") ValidatorGroupMarkedIneligibleHash = TopicHashHex("ValidatorGroupMarkedIneligible(address)") ValidatorGroupVoteCastHash = TopicHashHex("ValidatorGroupVoteCast(address,address,uint256)") ValidatorGroupPendingVoteRevokedHash = TopicHashHex("ValidatorGroupPendingVoteRevoked(address,address,uint256)") ValidatorGroupVoteActivatedHash = TopicHashHex("ValidatorGroupVoteActivated(address,address,uint256,uint256)") ValidatorGroupActiveVoteRevokedHash = TopicHashHex("ValidatorGroupActiveVoteRevoked(address,address,uint256,uint256)") ProposalQueuedHash = TopicHashHex("ProposalQueued(uint256,address,uint256,uint256,uint256)") ProposalUpvotedHash = TopicHashHex("ProposalUpvoted(uint256,address,uint256)") ProposalUpvoteRevokedHash = TopicHashHex("ProposalUpvoteRevoked(uint256,address,uint256)") ProposalDequeuedHash = TopicHashHex("ProposalDequeued(uint256,uint256)") ProposalApprovedHash = TopicHashHex("ProposalApproved(uint256)") ProposalVotedHash = TopicHashHex("ProposalVoted(uint256,address,uint256,uint256)") ProposalExecutedHash = TopicHashHex("ProposalExecuted(uint256)") ProposalExpiredHash = TopicHashHex("ProposalExpired(uint256)") //GovernanceSlasher.sol SlashingApprovedHash = TopicHashHex("SlashingApproved(address,uint256)") GovernanceSlashPerformedHash = TopicHashHex("GovernanceSlashPerformed(address,uint256)") GoldLockedHash = TopicHashHex("GoldLocked(address,uint256)") GoldUnlockedHash = TopicHashHex("GoldUnlocked(address,uint256,uint256)") GoldRelockedHash = TopicHashHex("GoldRelocked(address,uint256)") GoldWithdrawnHash = TopicHashHex("GoldWithdrawn(address,uint256)") AccountSlashedHash = TopicHashHex("AccountSlashed(address,uint256,address,uint256)") TransferHash = TopicHashHex("Transfer(address,address,uint256)") TransferCommentHash = TopicHashHex("TransferComment(string)") //Transfer and TransferComment - same signatures as StableToken.sol ApprovalHash = TopicHashHex("Approval(address,address,uint256)") )
List of all relevant Topic Signatures in Keccak256 Hash Format
Functions ¶
func BlockIterator ¶
BlockIterator iterates over the blocks and performs the supplied extraction tasks
func CreateEventLogsTable ¶
CreateLogsTable creates the block_iterator_event_logs table
func CreateSnapshotDataTable ¶
func CreateStatusTable ¶
CreateStatusTable creates the block_iterator_status table
func CreateTagsTable ¶
func CreateTransactionsTable ¶
CreateTransactionsTable creates the block_iterator_transactions table
func DeleteTable ¶
DeleteTable deletes a table from a database
func DumpEventLog ¶
DumpEventLog inserts eventLog data into block_iterator_event_logs table
func DumpTagsRow ¶
func DumpTransaction ¶
func DumpTransaction(db *sql.DB, blockNumber *big.Int, timestamp string, txHash string, transaction *Transaction)
DumpTransaction inserts transaction data into block_iterator_transactions table
func GenerateTransactionTags ¶
GenerateTransactionTags is a block iterator task to tag transactions and store these tags to the database. The data source for this task is the output of the ProcessTransactions task. Hence, in the list of tasks passed to the BlockIterator, this task should NOT appear in the list before the ProcessTransactions task.
func GetHashOfTransactions ¶
GetHashOfTransactions returns all tx hashes in the given block (number)
func InitClients ¶
func InitClients()
InitClients initializes clients for RPC/IPC calls to the Celo blockchain
func ProcessEventLogs ¶
ProcessEventLogs retrieves all event logs generated in the block corresponding to the specified block number and then stores them in the database
func ProcessTransactions ¶
ProcessTransactions is a task to retrieve all transactions of the given block number, extract relevant information for each transaction and store it in the database
func ResetDatabase ¶
ResetDatabase deletes the block iterator tables if they exist and then creates fresh block iterator tables Table - block_iterator_status Table - block_iterator_transactions
func SetIterationStatusComplete ¶
SetIterationStatusComplete adds blocknumber to database and sets its value to be true
func TakeDailySnapshots ¶
TakeDailySnapshots evaluates if the block number is first block of UTC day and then takes a snapshot if that is indeed the case.
func TopicHashHex ¶
TopicHashHex returns Keccak256Hash of the topic signature in string format
Types ¶
type EventLog ¶
type EventLog struct { BlockLogIndex uint TxHash common.Hash TxLogIndex uint // This will be vLog.Topics[0].Hex() Topic string Details *types.Log }
EventLog contains relevant (to Icarus) details of a Celo event log
func EventLogFrom ¶
EventLogFrom generates an EventLog object given a *types.Log object
type EventLogs ¶
EventLogs is an Icarus wrapper over types.Log to define Value() and Scan()
type LogAccountSlashed ¶
type LogAccountSlashed struct { Slashed common.Address Penalty *big.Int Reporter common.Address Reward *big.Int }
LogAccountSlashed - AccountSlashed(address indexed slashed, uint256 penalty, address indexed reporter, uint256 reward)
type LogApproval ¶
LogApproval - to capture details from an event log of form Approval
type LogGoldLocked ¶
LogGoldLocked - GoldLocked(address indexed account, uint256 value)
type LogGoldRelocked ¶
LogGoldRelocked - GoldRelocked(address indexed account, uint256 value)
type LogGoldUnlocked ¶
LogGoldUnlocked - GoldUnlocked(address indexed account, uint256 value, uint256 available)
type LogGoldWithdrawn ¶
LogGoldWithdrawn - GoldWithdrawn(address indexed account, uint256 value)
type LogGovernanceSlashPerformed ¶
LogGovernanceSlashPerformed - GovernanceSlashPerformed(address indexed account, uint256 amount)
type LogProposalDequeued ¶
LogProposalDequeued - ProposalDequeued(uint256 indexed proposalId, uint256 timestamp)
type LogProposalQueued ¶
type LogProposalQueued struct { ProposalId *big.Int Proposer common.Address TransactionCount *big.Int Deposit *big.Int Timestamp *big.Int }
LogProposalQueued- ProposalQueued(uint256 indexed proposalId, address indexed proposer, uint256 transactionCount, uint256 deposit, uint256 timestamp)
type LogProposalUpvoteRevoked ¶
type LogProposalUpvoteRevoked struct { ProposalId *big.Int Account common.Address RevokedUpvotes *big.Int }
LogProposalUpvoteRevoked - ProposalUpvoteRevoked(uint256 indexed proposalId, address indexed account, uint256 revokedUpvotes)
type LogProposalUpvoted ¶
LogProposalUpvoted - ProposalUpvoted(uint256 indexed proposalId, address indexed account, uint256 upvotes)
type LogProposalVoted ¶
type LogProposalVoted struct { ProposalId *big.Int Account common.Address Value *big.Int Weight *big.Int }
LogProposalVoted - ProposalVoted(uint256 indexed proposalId, address indexed account, uint256 value, uint256 weight)
type LogSlashingApproved ¶
LogSlashingApproved - SlashingApproved(address indexed account, uint256 amount)
type LogTransfer ¶
LogTransfer - to capture details from an event log of form Transfer
type LogTransferComment ¶
type LogTransferComment struct {
Comment string
}
LogTransferComment - to capture details from an event log of form TransferComment
type LogValidatorGroupActiveVoteRevoked ¶
type LogValidatorGroupActiveVoteRevoked struct { Account common.Address Group common.Address Value *big.Int Units *big.Int }
LogValidatorGroupActiveVoteRevoked - ValidatorGroupActiveVoteRevoked(address indexed account, address indexed group, uint256 value, uint256 units)
type LogValidatorGroupPendingVoteRevoked ¶
type LogValidatorGroupPendingVoteRevoked struct { Account common.Address Group common.Address Value *big.Int }
LogValidatorGroupPendingVoteRevoked - ValidatorGroupPendingVoteRevoked(address indexed account, address indexed group, uint256 value)
type LogValidatorGroupVoteActivated ¶
type LogValidatorGroupVoteActivated struct { Account common.Address Group common.Address Value *big.Int Units *big.Int }
LogValidatorGroupVoteActivated - ValidatorGroupVoteActivated(address indexed account, address indexed group, uint256 value, uint256 units)
type LogValidatorGroupVoteCast ¶
type LogValidatorGroupVoteCast struct { Account common.Address Group common.Address Value *big.Int }
LogValidatorGroupVoteCast - ValidatorGroupVoteCast(address indexed account, address indexed group, uint256 value)
type Tag ¶
type Tag struct { Name string `json:"eventname"` Source string `json:"source"` Parameters map[string]string `json:"parameters"` // contains filtered or unexported fields }
Tag represents an Icarus tag on a Celo transaction
func ProcessTags ¶
ProcessTags generates tags for a transaction from the logs provided
type Tags ¶
type Tags []*Tag
Tags is a type representation for a slice of Tag pointers
type Transaction ¶
type Transaction struct { Nonce uint64 `json:"nonce"` GasLimit uint64 `json:"gasLimit"` GasPrice *big.Int `json:"gasPrice"` GasUsed uint64 `json:"gasUsed"` FeeCurrency *common.Address `json:"feeCurrency"` GatewayFeeRecipient *common.Address `json:"gatewayFeeRecipient"` GatewayFee *big.Int `json:"gatewayFee"` To *common.Address `json:"to"` Val *big.Int `json:"value"` Raw *types.Transaction `json:"raw"` }
Transaction struct contains relevant (to Icarus) details of a Celo transaction
func TransactionFrom ¶
func TransactionFrom(tx *types.Transaction, gasReceipt *blockchain.GasReceipt) *Transaction
TransactionFrom creates a Transaction object given a *types.Transaction object and gas details
func (*Transaction) Scan ¶
func (tx *Transaction) Scan(value interface{}) error
Scan decodes a JSON-encoded value into a Transaction struct
type TransactionDetailed ¶
type TransactionDetailed struct { BlockNumber string `json:"blockNumber"` Timestamp string `json:"timestamp"` TxHash string `json:"hash"` Details Transaction `json:"details"` From string `json:"from"` To string `json:"to"` ELogs EventLogs `json:"logs"` Tags Tags `json:"tags"` }
TransactionDetailed wraps relevant details of a transaction including its event logs + tags generated by Icarus for the transaction
func FetchTransactionByTxHash ¶
func FetchTransactionByTxHash(db *sql.DB, txHash string) (*TransactionDetailed, error)
FetchTransactionByTxHash returns all transactions involving the given address upto the given blockheight (with tagging metadata)
func FetchTransactions ¶
func FetchTransactions(db *sql.DB, address string, uptoBlockNumber *big.Int, limit int, offset int, sourceContract string) ([]*TransactionDetailed, error)
FetchTransactions returns all transactions involving the given address upto the given blockheight (with tagging metadata)