aboutsummaryrefslogblamecommitdiff
path: root/eth/backend.go
blob: 02a23cc259837e90d8dd22a3f931b4181588ef65 (plain) (tree)


























                                                                                  
                                                    
                                         

                                                 


                                                    
                                                    






                                                           




                                                        



                                               
                                                   


                                                










                                                         



                                                


































                                                                                                       

                                  
                                      
















                                                                     




                                                    
















                                                                                                                                                                            






                                                                                                                                                                  
         
                                                                                               









                                                                                      
                                                                                                                                                 





                                                                                                       
                                                       
                                    






























                                                                                                                                                                
                                                                                                                                                     















                                                                                   








                                                                                                                                                                                                                                 
                                                                                                                 





















                                                                                                     

                                                                                                                                





                                                                                                       
                                                                                                                                                                                                                
                                       






























                                                                            




                                                                                                                       





























































































































                                                                                                                          










                                                                      













                                                                                      


                                                                                             
 

                                      





































                                                                                                                      






                                                                       





                                                                                
                                                 















                                                                                                                                                    


                                                 











                                                                                


                                        


                                  







                             












                                     



                                                    







                                                 
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// Package eth implements the Ethereum protocol.
package eth

import (
	"errors"
	"fmt"
	"math/big"
	"runtime"
	"sync"
	"sync/atomic"

	"github.com/ava-labs/coreth/consensus/dummy"
	"github.com/ava-labs/coreth/core"
	"github.com/ava-labs/coreth/eth/filters"
	"github.com/ava-labs/coreth/eth/gasprice"
	"github.com/ava-labs/coreth/internal/ethapi"
	"github.com/ava-labs/coreth/miner"
	"github.com/ava-labs/coreth/node"
	myparams "github.com/ava-labs/coreth/params"
	"github.com/ava-labs/go-ethereum/accounts"
	"github.com/ava-labs/go-ethereum/accounts/abi/bind"
	"github.com/ava-labs/go-ethereum/common"
	"github.com/ava-labs/go-ethereum/common/hexutil"
	"github.com/ava-labs/go-ethereum/consensus"
	"github.com/ava-labs/go-ethereum/consensus/clique"
	"github.com/ava-labs/go-ethereum/consensus/ethash"
	"github.com/ava-labs/go-ethereum/core/bloombits"
	"github.com/ava-labs/go-ethereum/core/rawdb"
	"github.com/ava-labs/go-ethereum/core/types"
	"github.com/ava-labs/go-ethereum/core/vm"
	"github.com/ava-labs/go-ethereum/eth/downloader"
	"github.com/ava-labs/go-ethereum/ethdb"
	"github.com/ava-labs/go-ethereum/event"
	"github.com/ava-labs/go-ethereum/log"
	"github.com/ava-labs/go-ethereum/p2p"
	//"github.com/ava-labs/go-ethereum/p2p/enr"
	"github.com/ava-labs/go-ethereum/params"
	"github.com/ava-labs/go-ethereum/rlp"
	"github.com/ava-labs/go-ethereum/rpc"
)

type LesServer interface {
	Start(srvr *p2p.Server)
	Stop()
	APIs() []rpc.API
	Protocols() []p2p.Protocol
	SetBloomBitsIndexer(bbIndexer *core.ChainIndexer)
	SetContractBackend(bind.ContractBackend)
}

type BackendCallbacks struct {
	OnQueryAcceptedBlock func() *types.Block
}

// Ethereum implements the Ethereum full node service.
type Ethereum struct {
	config *Config

	// Channel for shutting down the service
	shutdownChan chan bool

	server *p2p.Server

	// Handlers
	txPool          *core.TxPool
	blockchain      *core.BlockChain
	protocolManager *ProtocolManager
	lesServer       LesServer

	// DB interfaces
	chainDb ethdb.Database // Block chain database

	eventMux       *event.TypeMux
	engine         consensus.Engine
	accountManager *accounts.Manager

	bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
	bloomIndexer  </