Skip to content

Instantly share code, notes, and snippets.

@s1na
Last active March 3, 2023 09:32
Show Gist options
  • Save s1na/05f2d241b07372b41ba1747ce6e098b7 to your computer and use it in GitHub Desktop.
Save s1na/05f2d241b07372b41ba1747ce6e098b7 to your computer and use it in GitHub Desktop.
Abigen v2
// Code generated via abigen V2 - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package db
import (
"errors"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = abi.ConvertType
)
// DBStats is an auto generated low-level Go binding around an user-defined struct.
type DBStats struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
}
// DbMetaData contains all meta data concerning the Db contract.
var DbMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"key\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"Insert\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"key\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"KeyedInsert\",\"type\":\"event\"},{\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"clearBalance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"k\",\"type\":\"uint256\"}],\"name\":\"get\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNamedStatParams\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inserts\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"mods\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getStatParams\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getStatsStruct\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inserts\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"mods\",\"type\":\"uint256\"}],\"internalType\":\"structDB.Stats\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"k\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"v\",\"type\":\"uint256\"}],\"name\":\"insert\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]",
Bin: "0x60806040526000805534801561001457600080fd5b50604051806060016040528060008152602001600081526020016000815250600360008201518160000155602082015181600101556040820151816002015590505061065a806100656000396000f3fe6080604052600436106100595760003560e01c80631d834a1b146100db5780636fcb9c70146101185780639507d39a14610145578063caf5f67d14610182578063e369ba3b14610199578063ee8161e0146101c657610077565b36610077573460008082825461006f919061043d565b925050819055005b34801561008357600080fd5b50600036606082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509050915050805190602001f35b3480156100e757600080fd5b5061010260048036038101906100fd91906104a2565b6101f1565b60405161010f91906104f1565b60405180910390f35b34801561012457600080fd5b5061012d610326565b60405161013c9392919061050c565b60405180910390f35b34801561015157600080fd5b5061016c60048036038101906101679190610543565b610348565b60405161017991906104f1565b60405180910390f35b34801561018e57600080fd5b50610197610380565b005b3480156101a557600080fd5b506101ae610389565b6040516101bd9392919061050c565b60405180910390f35b3480156101d257600080fd5b506101db6103ab565b6040516101e891906105c1565b60405180910390f35b6000808203610207576002805490509050610320565b600060016000858152602001908152602001600020540361026b57600283908060018154018082558091505060019003906000526020600020016000909190919091505560036001016000815480929190610261906105dc565b9190505550610287565b60036002016000815480929190610281906105dc565b91905055505b8160016000858152602001908152602001600020819055507f8b39ff47dca36ab5b8b80845238af53aa579625ac7fb173dc09376adada4176983836002805490506040516102d79392919061050c565b60405180910390a1827f40bed843c6c5f72002f9b469cf4c1ee9f7fb1eb48f091c1267970f98522ac02d8360405161030f91906104f1565b60405180910390a260028054905090505b92915050565b6000806000600360000154600360010154600360020154925092509250909192565b600060036000016000815480929190610360906105dc565b919050555060016000838152602001908152602001600020549050919050565b60008081905550565b6000806000600360000154600360010154600360020154925092509250909192565b6103b36103e3565b60036040518060600160405290816000820154815260200160018201548152602001600282015481525050905090565b60405180606001604052806000815260200160008152602001600081525090565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061044882610404565b915061045383610404565b925082820190508082111561046b5761046a61040e565b5b92915050565b600080fd5b61047f81610404565b811461048a57600080fd5b50565b60008135905061049c81610476565b92915050565b600080604083850312156104b9576104b8610471565b5b60006104c78582860161048d565b92505060206104d88582860161048d565b9150509250929050565b6104eb81610404565b82525050565b600060208201905061050660008301846104e2565b92915050565b600060608201905061052160008301866104e2565b61052e60208301856104e2565b61053b60408301846104e2565b949350505050565b60006020828403121561055957610558610471565b5b60006105678482850161048d565b91505092915050565b61057981610404565b82525050565b6060820160008201516105956000850182610570565b5060208201516105a86020850182610570565b5060408201516105bb6040850182610570565b50505050565b60006060820190506105d6600083018461057f565b92915050565b60006105e782610404565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036106195761061861040e565b5b60018201905091905056fea264697066735822122080a06bf44190fb9a91d0b71ce837df6cd8c8f5a467297e9ab38c6982de1ae9cc64736f6c63430008110033",
}
// DbInstance represents a deployed instance of the Db contract.
type DbInstance struct {
Db
address common.Address
backend bind.ContractBackend
}
func NewDbInstance(c *Db, address common.Address, backend bind.ContractBackend) *DbInstance {
return &DbInstance{Db: *c, address: address, backend: backend}
}
func (i *DbInstance) Address() common.Address {
return i.address
}
func (i *DbInstance) Backend() bind.ContractBackend {
return i.backend
}
// Db is an auto generated Go binding around an Ethereum contract.
type Db struct {
abi abi.ABI
deployCode []byte
}
// NewDb creates a new instance of Db.
func NewDb() (*Db, error) {
parsed, err := DbMetaData.GetAbi()
if err != nil {
return nil, err
}
code := common.Hex2Bytes(DbMetaData.Bin)
return &Db{abi: *parsed, deployCode: code}, nil
}
func (_Db *Db) DeployCode() []byte {
return _Db.deployCode
}
func (_Db *Db) PackConstructor() ([]byte, error) {
return _Db.abi.Pack("")
}
// ClearBalance is a free data retrieval call binding the contract method 0xcaf5f67d.
//
// Solidity: function clearBalance() returns()
func (_Db *Db) PackClearBalance() ([]byte, error) {
return _Db.abi.Pack("clearBalance")
}
// Get is a free data retrieval call binding the contract method 0x9507d39a.
//
// Solidity: function get(uint256 k) returns(uint256)
func (_Db *Db) PackGet(k *big.Int) ([]byte, error) {
return _Db.abi.Pack("get", k)
}
func (_Db *Db) UnpackGet(data []byte) (*big.Int, error) {
out, err := _Db.abi.Unpack("get", data)
if err != nil {
return *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
return out0, err
}
// GetNamedStatParams is a free data retrieval call binding the contract method 0xe369ba3b.
//
// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods)
func (_Db *Db) PackGetNamedStatParams() ([]byte, error) {
return _Db.abi.Pack("getNamedStatParams")
}
func (_Db *Db) UnpackGetNamedStatParams(data []byte) (struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
}, error) {
out, err := _Db.abi.Unpack("getNamedStatParams", data)
outstruct := new(struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
})
if err != nil {
return *outstruct, err
}
outstruct.Gets = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
outstruct.Inserts = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
outstruct.Mods = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
return *outstruct, err
}
// GetStatParams is a free data retrieval call binding the contract method 0x6fcb9c70.
//
// Solidity: function getStatParams() view returns(uint256, uint256, uint256)
func (_Db *Db) PackGetStatParams() ([]byte, error) {
return _Db.abi.Pack("getStatParams")
}
func (_Db *Db) UnpackGetStatParams(data []byte) (struct {
Arg *big.Int
Arg0 *big.Int
Arg1 *big.Int
}, error) {
out, err := _Db.abi.Unpack("getStatParams", data)
outstruct := new(struct {
Arg *big.Int
Arg0 *big.Int
Arg1 *big.Int
})
if err != nil {
return *outstruct, err
}
outstruct.Arg = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
outstruct.Arg0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
outstruct.Arg1 = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
return *outstruct, err
}
// GetStatsStruct is a free data retrieval call binding the contract method 0xee8161e0.
//
// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256))
func (_Db *Db) PackGetStatsStruct() ([]byte, error) {
return _Db.abi.Pack("getStatsStruct")
}
func (_Db *Db) UnpackGetStatsStruct(data []byte) (DBStats, error) {
out, err := _Db.abi.Unpack("getStatsStruct", data)
if err != nil {
return *new(DBStats), err
}
out0 := *abi.ConvertType(out[0], new(DBStats)).(*DBStats)
return out0, err
}
// Insert is a free data retrieval call binding the contract method 0x1d834a1b.
//
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
func (_Db *Db) PackInsert(k *big.Int, v *big.Int) ([]byte, error) {
return _Db.abi.Pack("insert", k, v)
}
func (_Db *Db) UnpackInsert(data []byte) (*big.Int, error) {
out, err := _Db.abi.Unpack("insert", data)
if err != nil {
return *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
return out0, err
}
// DbInsert represents a Insert event raised by the Db contract.
type DbInsert struct {
Key *big.Int
Value *big.Int
Length *big.Int
Raw *types.Log // Blockchain specific contextual infos
}
func (_Db *Db) InsertEventID() common.Hash {
return common.HexToHash("0x8b39ff47dca36ab5b8b80845238af53aa579625ac7fb173dc09376adada41769")
}
func (_Db *Db) UnpackInsertEvent(log *types.Log) (*DbInsert, error) {
event := "Insert"
if log.Topics[0] != _Db.abi.Events[event].ID {
return nil, errors.New("event signature mismatch")
}
out := new(DbInsert)
if len(log.Data) > 0 {
if err := _Db.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
return nil, err
}
}
var indexed abi.Arguments
for _, arg := range _Db.abi.Events[event].Inputs {
if arg.Indexed {
indexed = append(indexed, arg)
}
}
if err := abi.ParseTopics(out, indexed, log.Topics[1:]); err != nil {
return nil, err
}
out.Raw = log
return out, nil
}
// DbKeyedInsert represents a KeyedInsert event raised by the Db contract.
type DbKeyedInsert struct {
Key *big.Int
Value *big.Int
Raw *types.Log // Blockchain specific contextual infos
}
func (_Db *Db) KeyedInsertEventID() common.Hash {
return common.HexToHash("0x40bed843c6c5f72002f9b469cf4c1ee9f7fb1eb48f091c1267970f98522ac02d")
}
func (_Db *Db) UnpackKeyedInsertEvent(log *types.Log) (*DbKeyedInsert, error) {
event := "KeyedInsert"
if log.Topics[0] != _Db.abi.Events[event].ID {
return nil, errors.New("event signature mismatch")
}
out := new(DbKeyedInsert)
if len(log.Data) > 0 {
if err := _Db.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
return nil, err
}
}
var indexed abi.Arguments
for _, arg := range _Db.abi.Events[event].Inputs {
if arg.Indexed {
indexed = append(indexed, arg)
}
}
if err := abi.ParseTopics(out, indexed, log.Topics[1:]); err != nil {
return nil, err
}
out.Raw = log
return out, nil
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract DB {
uint balance = 0;
mapping(uint => uint) private _store;
uint[] private _keys;
struct Stats {
uint gets;
uint inserts;
uint mods; // modifications
}
Stats _stats;
event KeyedInsert(uint indexed key, uint value);
event Insert(uint key, uint value, uint length);
constructor() {
_stats = Stats(0, 0, 0);
}
// insert adds a key value to the store, returning the new length of the store.
function insert(uint k, uint v) external returns (uint) {
// No need to store 0 values
if (v == 0) {
return _keys.length;
}
// Check if a key is being overriden
if (_store[k] == 0) {
_keys.push(k);
_stats.inserts++;
} else {
_stats.mods++;
}
_store[k] = v;
emit Insert(k, v, _keys.length);
emit KeyedInsert(k, v);
return _keys.length;
}
function get(uint k) public returns (uint) {
_stats.gets++;
return _store[k];
}
function getStatParams() public view returns (uint, uint, uint) {
return (_stats.gets, _stats.inserts, _stats.mods);
}
function getNamedStatParams() public view returns (uint gets, uint inserts, uint mods) {
return (_stats.gets, _stats.inserts, _stats.mods);
}
function getStatsStruct() public view returns (Stats memory) {
return _stats;
}
receive() external payable {
balance += msg.value;
}
fallback(bytes calldata _input) external returns (bytes memory _output) {
_output = _input;
}
}
package main
import (
"context"
"fmt"
"log"
"math/big"
"os"
"time"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
pkg "example/storage/db"
)
func main() {
backend, chainId, err := newClient()
if err != nil {
log.Fatal(err)
}
auth, err := newTransactor(chainId)
if err != nil {
log.Fatal(err)
}
db, err := pkg.NewDb()
if err != nil {
log.Fatal(err)
}
/*contractAddr, err := deploy(db, auth, backend)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Deployed addr: %s, txHash %s\n", contractAddr.Hex())*/
contractAddr := common.HexToAddress("0xc3cd232bC5382953896D1EBC1c16F312A1FDEA19")
instance := pkg.NewDbInstance(db, contractAddr, backend)
/*tx1, err := insert(db, contractAddr, auth, backend, big.NewInt(16), big.NewInt(32))
if err != nil {
log.Fatal(err)
}
fmt.Printf("Inserted via tx: %s\n", tx1.Hash().Hex())*/
callOpts := &bind.CallOpts{From: auth.From}
len, err := call(instance, callOpts)
if err != nil {
log.Fatal(err)
}
fmt.Printf("db value is: %s\n", len.String())
// Get past events
it, err := bind.FilterLogs(instance, &bind.FilterOpts{}, db.KeyedInsertEventID(), db.UnpackKeyedInsertEvent, []any{common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000000f")})
for it.Next() {
ev := it.Event
fmt.Printf("Insert event: %v, %v, %v\n", ev.Key, ev.Value, ev.Raw)
}
if err := it.Error(); err != nil {
fmt.Printf("Iterator errd: %v", err)
}
// Now watch future events
ch := make(chan *pkg.DbInsert)
sub, err := bind.WatchLogs(instance, &bind.WatchOpts{}, db.InsertEventID(), db.UnpackInsertEvent, ch)
if err != nil {
log.Fatalf("failed to watch logs: %v\n", err)
}
go func() {
time.Sleep(5 * time.Second)
insert(instance, auth, big.NewInt(21), big.NewInt(42))
}()
select {
case err := <-sub.Err():
fmt.Printf("subscription errd: %v\n", err)
case ev := <-ch:
fmt.Printf("Insert event: %v, %v, %v\n", ev.Key, ev.Value, ev.Raw)
}
}
func newClient() (bind.ContractBackend, *big.Int, error) {
client, err := ethclient.Dial("ws://127.0.0.1:8546")
if err != nil {
return nil, nil, err
}
num, err := client.BlockNumber(context.Background())
if err != nil {
return nil, nil, err
}
chainId, err := client.ChainID(context.Background())
if err != nil {
return nil, nil, err
}
fmt.Printf("Ethclient connected. BlockNumber: %d, ChainID: %d\n", num, chainId)
return client, chainId, nil
}
func newTransactor(chainId *big.Int) (*bind.TransactOpts, error) {
ksFile, err := os.Open("/Users/sina/dev/go/src/github.com/ethereum/go-ethereum/tmp-dev/keystore/UTC--2023-01-09T14-41-30.700077000Z--c25caf73f581a52b335baa39670b58fcc808fa01")
if err != nil {
return nil, err
}
auth, err := bind.NewTransactorWithChainID(ksFile, "", chainId)
if err != nil {
return nil, err
}
return auth, nil
}
func deploy(contract *pkg.Db, auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, error) {
input, err := contract.PackConstructor()
if err != nil {
log.Fatal(err)
}
addr, _, err := bind.DeployContract2(auth, contract.DeployCode(), input, backend)
return addr, err
}
func insert(db *pkg.DbInstance, auth *bind.TransactOpts, k, v *big.Int) (*types.Transaction, error) {
input, err := db.PackInsert(k, v)
if err != nil {
return nil, err
}
return bind.Transact2(db, auth, input)
}
func call(db *pkg.DbInstance, auth *bind.CallOpts) (*big.Int, error) {
input, err := db.PackGet(big.NewInt(15))
if err != nil {
return nil, err
}
return bind.Call2(db, auth, input, db.UnpackGet)
}
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package v1
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
_ = abi.ConvertType
)
// DBStats is an auto generated low-level Go binding around an user-defined struct.
type DBStats struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
}
// DbMetaData contains all meta data concerning the Db contract.
var DbMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"key\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"Insert\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"key\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"KeyedInsert\",\"type\":\"event\"},{\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"k\",\"type\":\"uint256\"}],\"name\":\"get\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNamedStatParams\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inserts\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"mods\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getStatParams\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getStatsStruct\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inserts\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"mods\",\"type\":\"uint256\"}],\"internalType\":\"structDB.Stats\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"k\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"v\",\"type\":\"uint256\"}],\"name\":\"insert\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]",
Bin: "0x60806040526000805534801561001457600080fd5b50604051806060016040528060008152602001600081526020016000815250600360008201518160000155602082015181600101556040820151816002015590505061062f806100656000396000f3fe60806040526004361061004e5760003560e01c80631d834a1b146100d05780636fcb9c701461010d5780639507d39a1461013a578063e369ba3b14610177578063ee8161e0146101a45761006c565b3661006c57346000808282546100649190610412565b925050819055005b34801561007857600080fd5b50600036606082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509050915050805190602001f35b3480156100dc57600080fd5b506100f760048036038101906100f29190610477565b6101cf565b60405161010491906104c6565b60405180910390f35b34801561011957600080fd5b50610122610304565b604051610131939291906104e1565b60405180910390f35b34801561014657600080fd5b50610161600480360381019061015c9190610518565b610326565b60405161016e91906104c6565b60405180910390f35b34801561018357600080fd5b5061018c61035e565b60405161019b939291906104e1565b60405180910390f35b3480156101b057600080fd5b506101b9610380565b6040516101c69190610596565b60405180910390f35b60008082036101e55760028054905090506102fe565b60006001600085815260200190815260200160002054036102495760028390806001815401808255809150506001900390600052602060002001600090919091909150556003600101600081548092919061023f906105b1565b9190505550610265565b6003600201600081548092919061025f906105b1565b91905055505b8160016000858152602001908152602001600020819055507f8b39ff47dca36ab5b8b80845238af53aa579625ac7fb173dc09376adada4176983836002805490506040516102b5939291906104e1565b60405180910390a1827f40bed843c6c5f72002f9b469cf4c1ee9f7fb1eb48f091c1267970f98522ac02d836040516102ed91906104c6565b60405180910390a260028054905090505b92915050565b6000806000600360000154600360010154600360020154925092509250909192565b60006003600001600081548092919061033e906105b1565b919050555060016000838152602001908152602001600020549050919050565b6000806000600360000154600360010154600360020154925092509250909192565b6103886103b8565b60036040518060600160405290816000820154815260200160018201548152602001600282015481525050905090565b60405180606001604052806000815260200160008152602001600081525090565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061041d826103d9565b9150610428836103d9565b92508282019050808211156104405761043f6103e3565b5b92915050565b600080fd5b610454816103d9565b811461045f57600080fd5b50565b6000813590506104718161044b565b92915050565b6000806040838503121561048e5761048d610446565b5b600061049c85828601610462565b92505060206104ad85828601610462565b9150509250929050565b6104c0816103d9565b82525050565b60006020820190506104db60008301846104b7565b92915050565b60006060820190506104f660008301866104b7565b61050360208301856104b7565b61051060408301846104b7565b949350505050565b60006020828403121561052e5761052d610446565b5b600061053c84828501610462565b91505092915050565b61054e816103d9565b82525050565b60608201600082015161056a6000850182610545565b50602082015161057d6020850182610545565b5060408201516105906040850182610545565b50505050565b60006060820190506105ab6000830184610554565b92915050565b60006105bc826103d9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036105ee576105ed6103e3565b5b60018201905091905056fea26469706673582212206a26a724645cff12e9c75117d8b90d76d70b2a3d028fa5e4ca79a72ab9bb323264736f6c63430008110033",
}
// DbABI is the input ABI used to generate the binding from.
// Deprecated: Use DbMetaData.ABI instead.
var DbABI = DbMetaData.ABI
// DbBin is the compiled bytecode used for deploying new contracts.
// Deprecated: Use DbMetaData.Bin instead.
var DbBin = DbMetaData.Bin
// DeployDb deploys a new Ethereum contract, binding an instance of Db to it.
func DeployDb(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Db, error) {
parsed, err := DbMetaData.GetAbi()
if err != nil {
return common.Address{}, nil, nil, err
}
if parsed == nil {
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
}
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DbBin), backend)
if err != nil {
return common.Address{}, nil, nil, err
}
return address, tx, &Db{DbCaller: DbCaller{contract: contract}, DbTransactor: DbTransactor{contract: contract}, DbFilterer: DbFilterer{contract: contract}}, nil
}
// Db is an auto generated Go binding around an Ethereum contract.
type Db struct {
DbCaller // Read-only binding to the contract
DbTransactor // Write-only binding to the contract
DbFilterer // Log filterer for contract events
}
// DbCaller is an auto generated read-only Go binding around an Ethereum contract.
type DbCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// DbTransactor is an auto generated write-only Go binding around an Ethereum contract.
type DbTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// DbFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type DbFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// DbSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type DbSession struct {
Contract *Db // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// DbCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type DbCallerSession struct {
Contract *DbCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// DbTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type DbTransactorSession struct {
Contract *DbTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// DbRaw is an auto generated low-level Go binding around an Ethereum contract.
type DbRaw struct {
Contract *Db // Generic contract binding to access the raw methods on
}
// DbCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type DbCallerRaw struct {
Contract *DbCaller // Generic read-only contract binding to access the raw methods on
}
// DbTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type DbTransactorRaw struct {
Contract *DbTransactor // Generic write-only contract binding to access the raw methods on
}
// NewDb creates a new instance of Db, bound to a specific deployed contract.
func NewDb(address common.Address, backend bind.ContractBackend) (*Db, error) {
contract, err := bindDb(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &Db{DbCaller: DbCaller{contract: contract}, DbTransactor: DbTransactor{contract: contract}, DbFilterer: DbFilterer{contract: contract}}, nil
}
// NewDbCaller creates a new read-only instance of Db, bound to a specific deployed contract.
func NewDbCaller(address common.Address, caller bind.ContractCaller) (*DbCaller, error) {
contract, err := bindDb(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &DbCaller{contract: contract}, nil
}
// NewDbTransactor creates a new write-only instance of Db, bound to a specific deployed contract.
func NewDbTransactor(address common.Address, transactor bind.ContractTransactor) (*DbTransactor, error) {
contract, err := bindDb(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &DbTransactor{contract: contract}, nil
}
// NewDbFilterer creates a new log filterer instance of Db, bound to a specific deployed contract.
func NewDbFilterer(address common.Address, filterer bind.ContractFilterer) (*DbFilterer, error) {
contract, err := bindDb(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &DbFilterer{contract: contract}, nil
}
// bindDb binds a generic wrapper to an already deployed contract.
func bindDb(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := DbMetaData.GetAbi()
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_Db *DbRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _Db.Contract.DbCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_Db *DbRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Db.Contract.DbTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Db *DbRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Db.Contract.DbTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_Db *DbCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _Db.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_Db *DbTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Db.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_Db *DbTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _Db.Contract.contract.Transact(opts, method, params...)
}
// GetNamedStatParams is a free data retrieval call binding the contract method 0xe369ba3b.
//
// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods)
func (_Db *DbCaller) GetNamedStatParams(opts *bind.CallOpts) (struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
}, error) {
var out []interface{}
err := _Db.contract.Call(opts, &out, "getNamedStatParams")
outstruct := new(struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
})
if err != nil {
return *outstruct, err
}
outstruct.Gets = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
outstruct.Inserts = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
outstruct.Mods = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
return *outstruct, err
}
// GetNamedStatParams is a free data retrieval call binding the contract method 0xe369ba3b.
//
// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods)
func (_Db *DbSession) GetNamedStatParams() (struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
}, error) {
return _Db.Contract.GetNamedStatParams(&_Db.CallOpts)
}
// GetNamedStatParams is a free data retrieval call binding the contract method 0xe369ba3b.
//
// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods)
func (_Db *DbCallerSession) GetNamedStatParams() (struct {
Gets *big.Int
Inserts *big.Int
Mods *big.Int
}, error) {
return _Db.Contract.GetNamedStatParams(&_Db.CallOpts)
}
// GetStatParams is a free data retrieval call binding the contract method 0x6fcb9c70.
//
// Solidity: function getStatParams() view returns(uint256, uint256, uint256)
func (_Db *DbCaller) GetStatParams(opts *bind.CallOpts) (*big.Int, *big.Int, *big.Int, error) {
var out []interface{}
err := _Db.contract.Call(opts, &out, "getStatParams")
if err != nil {
return *new(*big.Int), *new(*big.Int), *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
out2 := *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
return out0, out1, out2, err
}
// GetStatParams is a free data retrieval call binding the contract method 0x6fcb9c70.
//
// Solidity: function getStatParams() view returns(uint256, uint256, uint256)
func (_Db *DbSession) GetStatParams() (*big.Int, *big.Int, *big.Int, error) {
return _Db.Contract.GetStatParams(&_Db.CallOpts)
}
// GetStatParams is a free data retrieval call binding the contract method 0x6fcb9c70.
//
// Solidity: function getStatParams() view returns(uint256, uint256, uint256)
func (_Db *DbCallerSession) GetStatParams() (*big.Int, *big.Int, *big.Int, error) {
return _Db.Contract.GetStatParams(&_Db.CallOpts)
}
// GetStatsStruct is a free data retrieval call binding the contract method 0xee8161e0.
//
// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256))
func (_Db *DbCaller) GetStatsStruct(opts *bind.CallOpts) (DBStats, error) {
var out []interface{}
err := _Db.contract.Call(opts, &out, "getStatsStruct")
if err != nil {
return *new(DBStats), err
}
out0 := *abi.ConvertType(out[0], new(DBStats)).(*DBStats)
return out0, err
}
// GetStatsStruct is a free data retrieval call binding the contract method 0xee8161e0.
//
// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256))
func (_Db *DbSession) GetStatsStruct() (DBStats, error) {
return _Db.Contract.GetStatsStruct(&_Db.CallOpts)
}
// GetStatsStruct is a free data retrieval call binding the contract method 0xee8161e0.
//
// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256))
func (_Db *DbCallerSession) GetStatsStruct() (DBStats, error) {
return _Db.Contract.GetStatsStruct(&_Db.CallOpts)
}
// Get is a paid mutator transaction binding the contract method 0x9507d39a.
//
// Solidity: function get(uint256 k) returns(uint256)
func (_Db *DbTransactor) Get(opts *bind.TransactOpts, k *big.Int) (*types.Transaction, error) {
return _Db.contract.Transact(opts, "get", k)
}
// Get is a paid mutator transaction binding the contract method 0x9507d39a.
//
// Solidity: function get(uint256 k) returns(uint256)
func (_Db *DbSession) Get(k *big.Int) (*types.Transaction, error) {
return _Db.Contract.Get(&_Db.TransactOpts, k)
}
// Get is a paid mutator transaction binding the contract method 0x9507d39a.
//
// Solidity: function get(uint256 k) returns(uint256)
func (_Db *DbTransactorSession) Get(k *big.Int) (*types.Transaction, error) {
return _Db.Contract.Get(&_Db.TransactOpts, k)
}
// Insert is a paid mutator transaction binding the contract method 0x1d834a1b.
//
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
func (_Db *DbTransactor) Insert(opts *bind.TransactOpts, k *big.Int, v *big.Int) (*types.Transaction, error) {
return _Db.contract.Transact(opts, "insert", k, v)
}
// Insert is a paid mutator transaction binding the contract method 0x1d834a1b.
//
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
func (_Db *DbSession) Insert(k *big.Int, v *big.Int) (*types.Transaction, error) {
return _Db.Contract.Insert(&_Db.TransactOpts, k, v)
}
// Insert is a paid mutator transaction binding the contract method 0x1d834a1b.
//
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
func (_Db *DbTransactorSession) Insert(k *big.Int, v *big.Int) (*types.Transaction, error) {
return _Db.Contract.Insert(&_Db.TransactOpts, k, v)
}
// Fallback is a paid mutator transaction binding the contract fallback function.
//
// Solidity: fallback() returns()
func (_Db *DbTransactor) Fallback(opts *bind.TransactOpts, calldata []byte) (*types.Transaction, error) {
return _Db.contract.RawTransact(opts, calldata)
}
// Fallback is a paid mutator transaction binding the contract fallback function.
//
// Solidity: fallback() returns()
func (_Db *DbSession) Fallback(calldata []byte) (*types.Transaction, error) {
return _Db.Contract.Fallback(&_Db.TransactOpts, calldata)
}
// Fallback is a paid mutator transaction binding the contract fallback function.
//
// Solidity: fallback() returns()
func (_Db *DbTransactorSession) Fallback(calldata []byte) (*types.Transaction, error) {
return _Db.Contract.Fallback(&_Db.TransactOpts, calldata)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_Db *DbTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) {
return _Db.contract.RawTransact(opts, nil) // calldata is disallowed for receive function
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_Db *DbSession) Receive() (*types.Transaction, error) {
return _Db.Contract.Receive(&_Db.TransactOpts)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_Db *DbTransactorSession) Receive() (*types.Transaction, error) {
return _Db.Contract.Receive(&_Db.TransactOpts)
}
// DbInsertIterator is returned from FilterInsert and is used to iterate over the raw logs and unpacked data for Insert events raised by the Db contract.
type DbInsertIterator struct {
Event *DbInsert // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *DbInsertIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(DbInsert)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(DbInsert)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *DbInsertIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *DbInsertIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// DbInsert represents a Insert event raised by the Db contract.
type DbInsert struct {
Key *big.Int
Value *big.Int
Length *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterInsert is a free log retrieval operation binding the contract event 0x8b39ff47dca36ab5b8b80845238af53aa579625ac7fb173dc09376adada41769.
//
// Solidity: event Insert(uint256 key, uint256 value, uint256 length)
func (_Db *DbFilterer) FilterInsert(opts *bind.FilterOpts) (*DbInsertIterator, error) {
logs, sub, err := _Db.contract.FilterLogs(opts, "Insert")
if err != nil {
return nil, err
}
return &DbInsertIterator{contract: _Db.contract, event: "Insert", logs: logs, sub: sub}, nil
}
// WatchInsert is a free log subscription operation binding the contract event 0x8b39ff47dca36ab5b8b80845238af53aa579625ac7fb173dc09376adada41769.
//
// Solidity: event Insert(uint256 key, uint256 value, uint256 length)
func (_Db *DbFilterer) WatchInsert(opts *bind.WatchOpts, sink chan<- *DbInsert) (event.Subscription, error) {
logs, sub, err := _Db.contract.WatchLogs(opts, "Insert")
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(DbInsert)
if err := _Db.contract.UnpackLog(event, "Insert", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseInsert is a log parse operation binding the contract event 0x8b39ff47dca36ab5b8b80845238af53aa579625ac7fb173dc09376adada41769.
//
// Solidity: event Insert(uint256 key, uint256 value, uint256 length)
func (_Db *DbFilterer) ParseInsert(log types.Log) (*DbInsert, error) {
event := new(DbInsert)
if err := _Db.contract.UnpackLog(event, "Insert", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
// DbKeyedInsertIterator is returned from FilterKeyedInsert and is used to iterate over the raw logs and unpacked data for KeyedInsert events raised by the Db contract.
type DbKeyedInsertIterator struct {
Event *DbKeyedInsert // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *DbKeyedInsertIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(DbKeyedInsert)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(DbKeyedInsert)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *DbKeyedInsertIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *DbKeyedInsertIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// DbKeyedInsert represents a KeyedInsert event raised by the Db contract.
type DbKeyedInsert struct {
Key *big.Int
Value *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterKeyedInsert is a free log retrieval operation binding the contract event 0x40bed843c6c5f72002f9b469cf4c1ee9f7fb1eb48f091c1267970f98522ac02d.
//
// Solidity: event KeyedInsert(uint256 indexed key, uint256 value)
func (_Db *DbFilterer) FilterKeyedInsert(opts *bind.FilterOpts, key []*big.Int) (*DbKeyedInsertIterator, error) {
var keyRule []interface{}
for _, keyItem := range key {
keyRule = append(keyRule, keyItem)
}
logs, sub, err := _Db.contract.FilterLogs(opts, "KeyedInsert", keyRule)
if err != nil {
return nil, err
}
return &DbKeyedInsertIterator{contract: _Db.contract, event: "KeyedInsert", logs: logs, sub: sub}, nil
}
// WatchKeyedInsert is a free log subscription operation binding the contract event 0x40bed843c6c5f72002f9b469cf4c1ee9f7fb1eb48f091c1267970f98522ac02d.
//
// Solidity: event KeyedInsert(uint256 indexed key, uint256 value)
func (_Db *DbFilterer) WatchKeyedInsert(opts *bind.WatchOpts, sink chan<- *DbKeyedInsert, key []*big.Int) (event.Subscription, error) {
var keyRule []interface{}
for _, keyItem := range key {
keyRule = append(keyRule, keyItem)
}
logs, sub, err := _Db.contract.WatchLogs(opts, "KeyedInsert", keyRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(DbKeyedInsert)
if err := _Db.contract.UnpackLog(event, "KeyedInsert", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseKeyedInsert is a log parse operation binding the contract event 0x40bed843c6c5f72002f9b469cf4c1ee9f7fb1eb48f091c1267970f98522ac02d.
//
// Solidity: event KeyedInsert(uint256 indexed key, uint256 value)
func (_Db *DbFilterer) ParseKeyedInsert(log types.Log) (*DbKeyedInsert, error) {
event := new(DbKeyedInsert)
if err := _Db.contract.UnpackLog(event, "KeyedInsert", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment