MCPcopy Create free account
hub / github.com/SmartPool/smartpool-client / Configure

Method Configure

ethereum/network_client.go:36–80  ·  view source on GitHub ↗
(etherbase common.Address, extradata string)

Source from the content-addressed store, hash-verified

34}
35
36func (nc *NetworkClient) Configure(etherbase common.Address, extradata string) error {
37 client, err := nc.rpc.ClientVersion()
38 if err != nil {
39 return err
40 }
41 if strings.HasPrefix(client, "Geth") {
42 smartpool.Output.Printf("Trying to set etherbase to SmartPool contract address: %s...", etherbase.Hex())
43 err = nc.rpc.SetEtherbase(etherbase)
44 if err != nil {
45 smartpool.Output.Printf("Trying to set etherbase to SmartPool contract address failed: %s\n", err)
46 smartpool.Output.Printf("Please make sure you used Geth option --rpcapi \"db,eth,net,web3,miner\"\n")
47 return err
48 }
49 smartpool.Output.Printf("Done.\n")
50 smartpool.Output.Printf("Trying to set extradata to SmartPool extradata convention: %s...", extradata)
51 err = nc.rpc.SetExtradata(extradata)
52 if err != nil {
53 smartpool.Output.Printf("Trying to set extra data to SmartPool extradata convention failed: %s\n", err)
54 smartpool.Output.Printf("Please make sure you used Geth option --rpcapi \"db,eth,net,web3,miner\"\n")
55 return err
56 }
57 smartpool.Output.Printf("Done.\n")
58 } else if strings.HasPrefix(client, "Parity") {
59 smartpool.Output.Printf("Trying to set etherbase to SmartPool contract address: %s...", etherbase.Hex())
60 err = nc.rpc.SetEtherbase(etherbase)
61 if err != nil {
62 smartpool.Output.Printf("Trying to set author to SmartPool contract address failed: %s\n", err)
63 smartpool.Output.Printf("Please make sure you used Parity option --jsonrpc-apis \"web3,eth,net,parity,traces,rpc,parity_set\"\n")
64 return err
65 }
66 smartpool.Output.Printf("Done.\n")
67 smartpool.Output.Printf("Trying to set extradata to SmartPool extradata convention: %s...", extradata)
68 err = nc.rpc.SetExtradata(extradata)
69 if err != nil {
70 smartpool.Output.Printf("Trying to set extra data to SmartPool extradata convention failed: %s\n", err)
71 smartpool.Output.Printf("Please make sure you used Parity option --jsonrpc-apis \"web3,eth,net,parity,traces,rpc,parity_set\"\n")
72 return err
73 }
74 smartpool.Output.Printf("Done.\n")
75 } else {
76 return errors.New(
77 fmt.Sprintf("Unsupported client: %s", client))
78 }
79 return nil
80}
81
82func NewNetworkClient(rpc RPCClient, workpool *WorkPool) *NetworkClient {
83 return &NetworkClient{

Callers

nothing calls this directly

Implementers 1

NetworkClientethereum/network_client.go

Calls 5

ClientVersionMethod · 0.65
PrintfMethod · 0.65
SetEtherbaseMethod · 0.65
SetExtradataMethod · 0.65
HexMethod · 0.45

Tested by

no test coverage detected