Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockSource ¶
type BlockSource struct { C <-chan *ethereum.Block // The channel on which the blocks are delivered. // contains filtered or unexported fields }
BlockSource holds a channel that delivers blocks from Ethereum channel.
func New ¶
func New(rawurl string, cfg *Config) (*BlockSource, error)
New returns a new BlockSource containing a channel that will deliver the blocks from Ethereum network.
Example ¶
package main import ( "fmt" "math/big" "github.com/monetha/go-ethereum/blocksource" ) func main() { config := &blocksource.Config{StartBlock: big.NewInt(4760755), Confirmations: 1} source, err := blocksource.New("https://mainnet.infura.io/", config) if err != nil { panic(err) } i := 0 for b := range source.Blocks() { i++ fmt.Printf("New block arrived: %v\n", b.Number) if i == 10 { source.Close() } } }
Output:
func (*BlockSource) Blocks ¶
func (bs *BlockSource) Blocks() <-chan *ethereum.Block
Blocks returns the channel on which the blocks are delivered.
func (*BlockSource) Close ¶
func (bs *BlockSource) Close() (err error)
Close implements io.Closer interface.
type Config ¶
type Config struct { // StartBlock is the number of the block from which to start the delivery of blocks. // If number is nil, the latest known block that has specified number of confirmations // is used as start block. StartBlock *big.Int // Confirmations number indicates that the block must be delivered only when it has // the specified number of confirmations (number of blocks mined since delivered block). Confirmations uint }
Config contains parameters of BlockSource.
Click to show internal directories.
Click to hide internal directories.