Handle events
- Adds interfaces for developers to build handlers that update data in response to log events - Resolves #29
This commit is contained in:
@@ -3,10 +3,14 @@ package core
|
||||
import "math/big"
|
||||
|
||||
type Blockchain interface {
|
||||
GetAttribute(contract Contract, attributeName string, blockNumber *big.Int) (interface{}, error)
|
||||
GetAttributes(contract Contract) (ContractAttributes, error)
|
||||
GetBlockByNumber(blockNumber int64) Block
|
||||
GetLogs(contract Contract, startingBlockNumber *big.Int, endingBlockNumber *big.Int) ([]Log, error)
|
||||
LastBlock() *big.Int
|
||||
Node() Node
|
||||
GetAttributes(contract Contract) (ContractAttributes, error)
|
||||
GetAttribute(contract Contract, attributeName string, blockNumber *big.Int) (interface{}, error)
|
||||
GetLogs(contract Contract, startingBlockNumber *big.Int, endingBlockNumber *big.Int) ([]Log, error)
|
||||
}
|
||||
|
||||
type ContractDataFetcher interface {
|
||||
FetchContractData(abiJSON string, address string, method string, methodArg interface{}, result interface{}, blockNumber int64) error
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package core
|
||||
|
||||
type Node struct {
|
||||
GenesisBlock string
|
||||
NetworkId float64
|
||||
Id string
|
||||
NetworkID float64
|
||||
ID string
|
||||
ClientName string
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package core
|
||||
|
||||
type WatchedEvent struct {
|
||||
Name string `json:"name"` // name
|
||||
BlockNumber int64 `json:"block_number" db:"block_number"` // block_number
|
||||
Address string `json:"address"` // address
|
||||
TxHash string `json:"tx_hash" db:"tx_hash"` // tx_hash
|
||||
Index int64 `json:"index"` // index
|
||||
Topic0 string `json:"topic0"` // topic0
|
||||
Topic1 string `json:"topic1"` // topic1
|
||||
Topic2 string `json:"topic2"` // topic2
|
||||
Topic3 string `json:"topic3"` // topic3
|
||||
Data string `json:"data"` // data
|
||||
LogID int64 `json:"log_id" db:"id"`
|
||||
Name string `json:"name"`
|
||||
BlockNumber int64 `json:"block_number" db:"block_number"`
|
||||
Address string `json:"address"`
|
||||
TxHash string `json:"tx_hash" db:"tx_hash"`
|
||||
Index int64 `json:"index"`
|
||||
Topic0 string `json:"topic0"`
|
||||
Topic1 string `json:"topic1"`
|
||||
Topic2 string `json:"topic2"`
|
||||
Topic3 string `json:"topic3"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user