github.com/bchainhub/blockbook@v0.3.2/bchain/coins/polis/polisrpc.go (about) 1 package polis 2 3 import ( 4 "blockbook/bchain" 5 "blockbook/bchain/coins/btc" 6 "encoding/json" 7 8 "github.com/golang/glog" 9 ) 10 11 // PolisRPC is an interface to JSON-RPC bitcoind service. 12 type PolisRPC struct { 13 *btc.BitcoinRPC 14 } 15 16 // NewPolisRPC returns new PolisRPC instance. 17 func NewPolisRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { 18 b, err := btc.NewBitcoinRPC(config, pushHandler) 19 if err != nil { 20 return nil, err 21 } 22 23 s := &PolisRPC{ 24 b.(*btc.BitcoinRPC), 25 } 26 s.RPCMarshaler = btc.JSONMarshalerV1{} 27 s.ChainConfig.SupportsEstimateSmartFee = false 28 29 return s, nil 30 } 31 32 // Initialize initializes PolisRPC instance. 33 func (b *PolisRPC) Initialize() error { 34 ci, err := b.GetChainInfo() 35 if err != nil { 36 return err 37 } 38 chainName := ci.Chain 39 40 params := GetChainParams(chainName) 41 42 // always create parser 43 b.Parser = NewPolisParser(params, b.ChainConfig) 44 45 // parameters for getInfo request 46 if params.Net == MainnetMagic { 47 b.Testnet = false 48 b.Network = "livenet" 49 } else { 50 b.Testnet = true 51 b.Network = "testnet" 52 } 53 54 glog.Info("rpc: block chain ", params.Name) 55 56 return nil 57 }