github.com/jeffallen/go-ethereum@v1.1.4-0.20150910155051-571d3236c49c/common/registrar/ethreg/ethreg.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package ethreg
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/ethereum/go-ethereum/common/registrar"
    23  	"github.com/ethereum/go-ethereum/xeth"
    24  )
    25  
    26  // implements a versioned Registrar on an archiving full node
    27  type EthReg struct {
    28  	backend  *xeth.XEth
    29  	registry *registrar.Registrar
    30  }
    31  
    32  func New(xe *xeth.XEth) (self *EthReg) {
    33  	self = &EthReg{backend: xe}
    34  	self.registry = registrar.New(xe)
    35  	return
    36  }
    37  
    38  func (self *EthReg) Registry() *registrar.Registrar {
    39  	return self.registry
    40  }
    41  
    42  func (self *EthReg) Resolver(n *big.Int) *registrar.Registrar {
    43  	xe := self.backend
    44  	if n != nil {
    45  		xe = self.backend.AtStateNum(n.Int64())
    46  	}
    47  	return registrar.New(xe)
    48  }