good morning!!!!

Skip to content
Snippets Groups Projects
Select Git revision
  • 61d67f2ae965a9a1113084f2352e2c2dd97ab9a7
  • master default protected
  • v0.2.16-candidate
  • shivam/rpcAddBorTx
  • default-cli-config
  • shivam/minerRecommitFix
  • vcastellm/pos-296-bump-go-version-in-bor-and-heimdall
  • shivam/ethstats-backend-fix
  • v0.2.16-beta1-candidate
  • v0.2.15-beta3-candidate
  • shivam/newCli-IPC
  • v0.3.0-dev
  • checkpoint-whitelist-master
  • shivam/codecov
  • jdkanani/fix-typo-log
  • shivam/hardcoded-spans-v0.2.14
  • shivam/hardcoded-spans
  • shivam/fast-state-sync
  • shivam/fast-state-sync-master
  • gethv1.10.15-merge
  • fix-txpool-2
  • v0.2.14-tmp-span-hotfix
  • v0.2.15-beta2
  • v0.2.15-beta1
  • v0.3.0-beta3
  • v0.3.0-beta2
  • v0.3.0-beta1
  • v0.2.14
  • v0.2.13
  • v0.2.13-beta2
  • v0.2.13-beta1
  • v0.2.12
  • v0.2.12-beta3
  • v0.2.12-beta1
  • v0.2.12-beta2
  • v0.2.11
  • v0.2.10
  • v0.2.10-beta2
  • v0.2.9
  • v0.2.9-beta1
  • v0.2.8
41 results

server.go

Blame
  • Forked from github / maticnetwork / bor
    13383 commits behind the upstream repository.
    user avatar
    Jeffrey Wilcke authored
    f17930eb
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    server.go 1006 B
    package main
    
    import (
      "container/list"
      "time"
    )
    
    type Server struct {
      // Channel for shutting down the server
      shutdownChan chan bool
      // DB interface
      db          *LDBDatabase
      // Peers (NYI)
      peers       *list.List
    }
    
    func NewServer() (*Server, error) {
      db, err := NewLDBDatabase()
      if err != nil {
        return nil, err
      }
    
      server := &Server{
        shutdownChan:    make(chan bool),
        db:              db,
        peers:           list.New(),
      }
    
      return server, nil
    }
    
    // Start the server
    func (s *Server) Start() {
      // For now this function just blocks the main thread
      for {
        time.Sleep( time.Second )
      }
    }
    
    func (s *Server) Stop() {
      // Close the database
      defer s.db.Close()
    
      // Loop thru the peers and close them (if we had them)
      for e := s.peers.Front(); e != nil; e = e.Next() {
        // peer close etc
      }
    
      s.shutdownChan <- true
    }
    
    // This function will wait for a shutdown and resumes main thread execution
    func (s *Server) WaitForShutdown() {
      <- s.shutdownChan
    }