batch_script

package module
v0.0.0-...-6a00778 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

batch-script

A tool to run a Cadence script against all accounts

Fetching all contracts

To fetch all contracts as a CSV file:

go run ./cmd/get_contracts/main.go > contracts.csv

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	BatchSize:         1000,
	AtBlockHeight:     0,
	FlowAccessNodeURL: "access.mainnet.nodes.onflow.org:9000",
	Chain:             flow.Mainnet,
	ConcurrentClients: 10,
	Pause:             500 * time.Millisecond,
}
View Source
var GetContracts string

Functions

func BatchScript

func BatchScript(
	ctx context.Context,
	log zerolog.Logger,
	conf Config,
	script string,
	handler func(cadence.Value),
	retryOnErrors bool,
) error

func NewGetContractsHandler

func NewGetContractsHandler(handler GetContractsHandler) func(value cadence.Value)

Types

type AddressProvider

type AddressProvider struct {
	// contains filtered or unexported fields
}

AddressProvider Is used to get all the addresses that exists at a certain referenceBlockId

func InitAddressProvider

func InitAddressProvider(
	ctx context.Context,
	log zerolog.Logger,
	chain flow.ChainID,
	referenceBlockID flow.Identifier,
	client *client.Client,
	pause time.Duration,
) (*AddressProvider, error)

InitAddressProvider uses bisection to get the last existing address.

func (*AddressProvider) GenerateAddressBatches

func (p *AddressProvider) GenerateAddressBatches(addressChan chan<- []flow.Address, batchSize int)

func (*AddressProvider) GetNextAddress

func (p *AddressProvider) GetNextAddress() (address flow.Address, isOutOfBounds bool)

func (*AddressProvider) LastAddress

func (p *AddressProvider) LastAddress() flow.Address

type Config

type Config struct {
	// BachSize is the number of addresses for which to run each script
	BatchSize int
	// 0 is treated as the latest block height.
	AtBlockHeight     uint64
	FlowAccessNodeURL string
	Chain             flow.ChainID
	ConcurrentClients int
	Pause             time.Duration
}

Config defines that application's config

type GetContractsHandler

type GetContractsHandler func(address cadence.Address, contractName, contractCode string, err error)

Directories

Path Synopsis
cmd
get_contracts
Get all contracts from a network and write them as a CSV file to standard output.
Get all contracts from a network and write them as a CSV file to standard output.

Jump to

Keyboard shortcuts

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