Browse Source

shifted log out, renamed to 'node' to be generic

master
Loki Verloren 6 months ago
parent
commit
dadc053d0b

+ 1
- 1
addrmgr/addrmanager.go View File

@@ -27,7 +27,7 @@ import (
27 27
 
28 28
 	"git.parallelcoin.io/dev/btcd/addrmgr/amc"
29 29
 	"git.parallelcoin.io/dev/btcd/addrmgr/known"
30
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
30
+	"git.parallelcoin.io/dev/btcd/node/cnf"
31 31
 	"git.parallelcoin.io/dev/btcd/chaincfg/chainhash"
32 32
 	"git.parallelcoin.io/dev/btcd/wire"
33 33
 )

+ 1
- 1
connmgr/connmanager.go View File

@@ -12,7 +12,7 @@ import (
12 12
 	"sync/atomic"
13 13
 	"time"
14 14
 
15
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
15
+	"git.parallelcoin.io/dev/btcd/node/cnf"
16 16
 )
17 17
 
18 18
 // maxFailedAttempts is the maximum number of successive failed connection

+ 1
- 1
connmgr/seed.go View File

@@ -11,7 +11,7 @@ import (
11 11
 	"strconv"
12 12
 	"time"
13 13
 
14
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
14
+	"git.parallelcoin.io/dev/btcd/node/cnf"
15 15
 	"git.parallelcoin.io/dev/btcd/chaincfg"
16 16
 	"git.parallelcoin.io/dev/btcd/wire"
17 17
 )

+ 3
- 3
main.go View File

@@ -6,8 +6,8 @@ import (
6 6
 	"runtime"
7 7
 	"runtime/debug"
8 8
 
9
-	"git.parallelcoin.io/dev/btcd/btcd"
10 9
 	"git.parallelcoin.io/dev/btcd/limits"
10
+	"git.parallelcoin.io/dev/btcd/node"
11 11
 )
12 12
 
13 13
 func main() {
@@ -30,7 +30,7 @@ func main() {
30 30
 	// the return isService flag is true, exit now since we ran as a
31 31
 	// service.  Otherwise, just fall through to normal operation.
32 32
 	if runtime.GOOS == "windows" {
33
-		isService, err := btcd.WinServiceMain()
33
+		isService, err := node.WinServiceMain()
34 34
 		if err != nil {
35 35
 			fmt.Println(err)
36 36
 			os.Exit(1)
@@ -41,7 +41,7 @@ func main() {
41 41
 	}
42 42
 
43 43
 	// Work around defer not working after os.Exit()
44
-	if err := btcd.Main(nil); err != nil {
44
+	if err := node.Main(nil); err != nil {
45 45
 		os.Exit(1)
46 46
 	}
47 47
 }

btcd/LICENSE → node/LICENSE View File


btcd/README.md → node/README.md View File


btcd/btcd.go → node/btcd.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 
@@ -7,18 +7,12 @@ import (
7 7
 	"os"
8 8
 	"path/filepath"
9 9
 
10
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
10
+	"git.parallelcoin.io/dev/btcd/node/cnf"
11
+	"git.parallelcoin.io/dev/btcd/node/log"
11 12
 	"git.parallelcoin.io/dev/btcd/database"
12 13
 	"git.parallelcoin.io/dev/btcd/util"
13 14
 )
14 15
 
15
-const (
16
-	// BlockDbNamePrefix is the prefix for the block database name.  The
17
-	// database type is appended to this value to form the full block
18
-	// database name.
19
-	BlockDbNamePrefix = "blocks"
20
-)
21
-
22 16
 // RemoveRegressionDB removes the existing regression test database if running
23 17
 // in regression test mode and it already exists.
24 18
 func RemoveRegressionDB(cfg *cnf.Config, dbPath string) error {
@@ -30,7 +24,7 @@ func RemoveRegressionDB(cfg *cnf.Config, dbPath string) error {
30 24
 	// Remove the old regression test database if it already exists.
31 25
 	fi, err := os.Stat(dbPath)
32 26
 	if err == nil {
33
-		BtcdLog.Infof("Removing regression test database from '%s'", dbPath)
27
+		log.Btcd.Infof("Removing regression test database from '%s'", dbPath)
34 28
 		if fi.IsDir() {
35 29
 			err := os.RemoveAll(dbPath)
36 30
 			if err != nil {
@@ -50,7 +44,7 @@ func RemoveRegressionDB(cfg *cnf.Config, dbPath string) error {
50 44
 // BlockDbPath returns the path to the block database given a database type.
51 45
 func BlockDbPath(cfg *cnf.Config, dbType string) string {
52 46
 	// The database name is based on the database type.
53
-	dbName := BlockDbNamePrefix + "_" + dbType
47
+	dbName := cnf.BlockDbNamePrefix + "_" + dbType
54 48
 	if dbType == "sqlite" {
55 49
 		dbName = dbName + ".db"
56 50
 	}
@@ -83,7 +77,7 @@ func WarnMultipleDBs(cfg *cnf.Config) {
83 77
 	// Warn if there are extra databases.
84 78
 	if len(duplicateDbPaths) > 0 {
85 79
 		selectedDbPath := BlockDbPath(cfg, cfg.DbType)
86
-		BtcdLog.Warnf("WARNING: There are multiple block chain databases "+
80
+		log.Btcd.Warnf("WARNING: There are multiple block chain databases "+
87 81
 			"using different database types.\nYou probably don't "+
88 82
 			"want to waste disk space by having more than one.\n"+
89 83
 			"Your current database is located at [%v].\nThe "+
@@ -102,7 +96,7 @@ func LoadBlockDB(cfg *cnf.Config) (database.DB, error) {
102 96
 	// handle it uniquely.  We also don't want to worry about the multiple
103 97
 	// database type warnings when running with the memory database.
104 98
 	if cfg.DbType == "memdb" {
105
-		BtcdLog.Infof("Creating block database in memory.")
99
+		log.Btcd.Infof("Creating block database in memory.")
106 100
 		db, err := database.Create(cfg.DbType)
107 101
 		if err != nil {
108 102
 			return nil, err
@@ -119,7 +113,7 @@ func LoadBlockDB(cfg *cnf.Config) (database.DB, error) {
119 113
 	// each run, so remove it now if it already exists.
120 114
 	RemoveRegressionDB(cfg, dbPath)
121 115
 
122
-	BtcdLog.Infof("Loading block database from '%s'", dbPath)
116
+	log.Btcd.Infof("Loading block database from '%s'", dbPath)
123 117
 	db, err := database.Open(cfg.DbType, dbPath, cfg.StateActiveNet.Params.Net)
124 118
 	if err != nil {
125 119
 		// Return the error if it's not because the database doesn't
@@ -141,6 +135,6 @@ func LoadBlockDB(cfg *cnf.Config) (database.DB, error) {
141 135
 		}
142 136
 	}
143 137
 
144
-	BtcdLog.Info("Block database loaded")
138
+	log.Btcd.Info("Block database loaded")
145 139
 	return db, nil
146 140
 }

btcd/checkpoint/sorter.go → node/checkpoint/sorter.go View File


btcd/cnf/config.go → node/cnf/config.go View File

@@ -4,7 +4,7 @@ import (
4 4
 	"net"
5 5
 	"time"
6 6
 
7
-	"git.parallelcoin.io/dev/btcd/btcd/nettype"
7
+	"git.parallelcoin.io/dev/btcd/node/nettype"
8 8
 	"git.parallelcoin.io/dev/btcd/btcutil"
9 9
 	"git.parallelcoin.io/dev/btcd/chaincfg"
10 10
 )
@@ -95,3 +95,10 @@ type Config struct {
95 95
 	StateWhitelists      []*net.IPNet
96 96
 	StateActiveNet       nettype.Params
97 97
 }
98
+
99
+const (
100
+	// BlockDbNamePrefix is the prefix for the block database name.  The
101
+	// database type is appended to this value to form the full block
102
+	// database name.
103
+	BlockDbNamePrefix = "blocks"
104
+)

btcd/config.go → node/config.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"bufio"
@@ -17,14 +17,15 @@ import (
17 17
 	"time"
18 18
 
19 19
 	"git.parallelcoin.io/dev/btcd/blockchain"
20
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
21
-	"git.parallelcoin.io/dev/btcd/btcd/defaults"
22
-	"git.parallelcoin.io/dev/btcd/btcd/nettype"
23
-	"git.parallelcoin.io/dev/btcd/btcd/version"
24 20
 	"git.parallelcoin.io/dev/btcd/btcutil"
25 21
 	"git.parallelcoin.io/dev/btcd/chaincfg"
26 22
 	"git.parallelcoin.io/dev/btcd/chaincfg/chainhash"
27 23
 	"git.parallelcoin.io/dev/btcd/connmgr"
24
+	"git.parallelcoin.io/dev/btcd/node/cnf"
25
+	"git.parallelcoin.io/dev/btcd/node/defaults"
26
+	"git.parallelcoin.io/dev/btcd/node/log"
27
+	"git.parallelcoin.io/dev/btcd/node/nettype"
28
+	"git.parallelcoin.io/dev/btcd/node/version"
28 29
 
29 30
 	// This is to trigger the init to load available db backends
30 31
 	_ "git.parallelcoin.io/dev/btcd/database/ffldb"
@@ -315,16 +316,16 @@ func LoadConfig() (*cnf.Config, []string, error) {
315 316
 
316 317
 	// Special show command to list supported subsystems and exit.
317 318
 	if cfg.DebugLevel == "show" {
318
-		fmt.Println("Supported subsystems", SupportedSubsystems())
319
+		fmt.Println("Supported subsystems", log.SupportedSubsystems())
319 320
 		os.Exit(0)
320 321
 	}
321 322
 
322 323
 	// Initialize log rotation.  After log rotation has been initialized, the
323 324
 	// logger variables may be used.
324
-	InitLogRotator(filepath.Join(cfg.LogDir, defaults.LogFilename))
325
+	log.InitRotator(filepath.Join(cfg.LogDir, defaults.LogFilename))
325 326
 
326 327
 	// Parse, validate, and set debug log level(s).
327
-	if err := ParseAndSetDebugLevels(cfg.DebugLevel); err != nil {
328
+	if err := log.ParseAndSetDebugLevels(cfg.DebugLevel); err != nil {
328 329
 		err := fmt.Errorf("%s: %v", funcName, err.Error())
329 330
 		fmt.Fprintln(os.Stderr, err)
330 331
 		fmt.Fprintln(os.Stderr, usageMessage)
@@ -451,7 +452,7 @@ func LoadConfig() (*cnf.Config, []string, error) {
451 452
 	}
452 453
 
453 454
 	if cfg.DisableRPC {
454
-		BtcdLog.Infof("RPC service is disabled")
455
+		log.Btcd.Infof("RPC service is disabled")
455 456
 	}
456 457
 
457 458
 	// Default RPC to listen on localhost only.
@@ -804,7 +805,7 @@ func LoadConfig() (*cnf.Config, []string, error) {
804 805
 	// done.  This prevents the warning on help messages and invalid
805 806
 	// options.  Note this should go directly before the return.
806 807
 	if configFileError != nil {
807
-		BtcdLog.Warnf("%v", configFileError)
808
+		log.Btcd.Warnf("%v", configFileError)
808 809
 	}
809 810
 
810 811
 	return &cfg, remainingArgs, nil

btcd/defaults/defaults.go → node/defaults/defaults.go View File


btcd/doc.go → node/doc.go View File

@@ -1,4 +1,4 @@
1
-/*Package btcd is a full-node bitcoin implementation written in Go.
1
+/*package node is a full-node bitcoin implementation written in Go.
2 2
 
3 3
 The default options are sane for most users.  This means btcd will work 'out of
4 4
 the box' for most users.  However, there are also a wide variety of flags that
@@ -120,4 +120,4 @@ Help Options:
120 120
   -h, --help           Show this help message
121 121
 
122 122
 */
123
-package btcd
123
+package node

btcd/gbtworkstate.go → node/gbtworkstate.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"bytes"
@@ -12,6 +12,7 @@ import (
12 12
 	"time"
13 13
 
14 14
 	"git.parallelcoin.io/dev/btcd/blockchain"
15
+	"git.parallelcoin.io/dev/btcd/node/log"
15 16
 	"git.parallelcoin.io/dev/btcd/btcjson"
16 17
 	"git.parallelcoin.io/dev/btcd/btcutil"
17 18
 	"git.parallelcoin.io/dev/btcd/chaincfg/chainhash"
@@ -294,7 +295,7 @@ func (state *GBTWorkState) UpdateBlockTemplate(s *RPCServer, useCoinbaseValue bo
294 295
 		state.prevHash = latestHash
295 296
 		state.minTimestamp = minTimestamp
296 297
 
297
-		RpcsLog.Debugf("Generated block template (timestamp %v, "+
298
+		log.Rpcs.Debugf("Generated block template (timestamp %v, "+
298 299
 			"target %s, merkle root %s)",
299 300
 			msgBlock.Header.Timestamp, targetDifficulty,
300 301
 			msgBlock.Header.MerkleRoot)
@@ -346,7 +347,7 @@ func (state *GBTWorkState) UpdateBlockTemplate(s *RPCServer, useCoinbaseValue bo
346 347
 		generator.UpdateBlockTime(msgBlock)
347 348
 		msgBlock.Header.Nonce = 0
348 349
 
349
-		RpcsLog.Debugf("Updated block template (timestamp %v, "+
350
+		log.Rpcs.Debugf("Updated block template (timestamp %v, "+
350 351
 			"target %s)", msgBlock.Header.Timestamp,
351 352
 			targetDifficulty)
352 353
 	}

btcd/log.go → node/log/log.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package log
2 2
 
3 3
 import (
4 4
 	"fmt"
@@ -23,13 +23,13 @@ import (
23 23
 	"github.com/jrick/logrotate/rotator"
24 24
 )
25 25
 
26
-// LogWriter implements an io.Writer that outputs to both standard output and
26
+// Writer implements an io.Writer that outputs to both standard output and
27 27
 // the write-end pipe of an initialized log rotator.
28
-type LogWriter struct{}
28
+type Writer struct{}
29 29
 
30
-func (LogWriter) Write(p []byte) (n int, err error) {
30
+func (Writer) Write(p []byte) (n int, err error) {
31 31
 	os.Stdout.Write(p)
32
-	LogRotator.Write(p)
32
+	Rotator.Write(p)
33 33
 	return len(p), nil
34 34
 }
35 35
 
@@ -40,72 +40,72 @@ func (LogWriter) Write(p []byte) (n int, err error) {
40 40
 //
41 41
 // Loggers can not be used before the log rotator has been initialized with a
42 42
 // log file.  This must be performed early during application startup by calling
43
-// InitLogRotator.
43
+// InitRotator.
44 44
 var (
45
-	// backendLog is the logging backend used to create all subsystem loggers.
45
+	// Backend is the logging backend used to create all subsystem loggers.
46 46
 	// The backend must not be used before the log rotator has been initialized,
47 47
 	// or data races and/or nil pointer dereferences will occur.
48
-	BackendLog = btclog.NewBackend(LogWriter{})
48
+	Backend = btclog.NewBackend(Writer{})
49 49
 
50
-	// logRotator is one of the logging outputs.  It should be closed on
50
+	// Rotator is one of the logging outputs.  It should be closed on
51 51
 	// application shutdown.
52
-	LogRotator *rotator.Rotator
53
-
54
-	AdxrLog = BackendLog.Logger("ADXR")
55
-	AmgrLog = BackendLog.Logger("AMGR")
56
-	CmgrLog = BackendLog.Logger("CMGR")
57
-	BcdbLog = BackendLog.Logger("BCDB")
58
-	BtcdLog = BackendLog.Logger("BTCD")
59
-	ChanLog = BackendLog.Logger("CHAN")
60
-	DiscLog = BackendLog.Logger("DISC")
61
-	IndxLog = BackendLog.Logger("INDX")
62
-	MinrLog = BackendLog.Logger("MINR")
63
-	PeerLog = BackendLog.Logger("PEER")
64
-	RpcsLog = BackendLog.Logger("RPCS")
65
-	ScrpLog = BackendLog.Logger("SCRP")
66
-	SrvrLog = BackendLog.Logger("SRVR")
67
-	SyncLog = BackendLog.Logger("SYNC")
68
-	TxmpLog = BackendLog.Logger("TXMP")
52
+	Rotator *rotator.Rotator
53
+
54
+	Adxr = Backend.Logger("ADXR")
55
+	Amgr = Backend.Logger("AMGR")
56
+	Cmgr = Backend.Logger("CMGR")
57
+	Bcdb = Backend.Logger("BCDB")
58
+	Btcd = Backend.Logger("BTCD")
59
+	Chan = Backend.Logger("CHAN")
60
+	Disc = Backend.Logger("DISC")
61
+	Indx = Backend.Logger("INDX")
62
+	Minr = Backend.Logger("MINR")
63
+	Peer = Backend.Logger("PEER")
64
+	Rpcs = Backend.Logger("RPCS")
65
+	Scrp = Backend.Logger("SCRP")
66
+	Srvr = Backend.Logger("SRVR")
67
+	Sync = Backend.Logger("SYNC")
68
+	Txmp = Backend.Logger("TXMP")
69 69
 )
70 70
 
71 71
 // Initialize package-global logger variables.
72 72
 func init() {
73
-	addrmgr.UseLogger(AmgrLog)
74
-	connmgr.UseLogger(CmgrLog)
75
-	database.UseLogger(BcdbLog)
76
-	blockchain.UseLogger(ChanLog)
77
-	indexers.UseLogger(IndxLog)
78
-	mining.UseLogger(MinrLog)
79
-	cpuminer.UseLogger(MinrLog)
80
-	peer.UseLogger(PeerLog)
81
-	txscript.UseLogger(ScrpLog)
82
-	netsync.UseLogger(SyncLog)
83
-	mempool.UseLogger(TxmpLog)
73
+	addrmgr.UseLogger(Amgr)
74
+	connmgr.UseLogger(Cmgr)
75
+	database.UseLogger(Bcdb)
76
+	blockchain.UseLogger(Chan)
77
+	indexers.UseLogger(Indx)
78
+	mining.UseLogger(Minr)
79
+	cpuminer.UseLogger(Minr)
80
+	peer.UseLogger(Peer)
81
+	txscript.UseLogger(Scrp)
82
+	netsync.UseLogger(Sync)
83
+	mempool.UseLogger(Txmp)
84 84
 }
85 85
 
86 86
 // subsystemLoggers maps each subsystem identifier to its associated logger.
87 87
 var subsystemLoggers = map[string]btclog.Logger{
88
-	"ADXR": AdxrLog,
89
-	"AMGR": AmgrLog,
90
-	"CMGR": CmgrLog,
91
-	"BCDB": BcdbLog,
92
-	"BTCD": BtcdLog,
93
-	"CHAN": ChanLog,
94
-	"DISC": DiscLog,
95
-	"INDX": IndxLog,
96
-	"MINR": MinrLog,
97
-	"PEER": PeerLog,
98
-	"RPCS": RpcsLog,
99
-	"SCRP": ScrpLog,
100
-	"SRVR": SrvrLog,
101
-	"SYNC": SyncLog,
102
-	"TXMP": TxmpLog,
88
+	"ADXR": Adxr,
89
+	"AMGR": Amgr,
90
+	"CMGR": Cmgr,
91
+	"BCDB": Bcdb,
92
+	"BTCD": Btcd,
93
+	"CHAN": Chan,
94
+	"DISC": Disc,
95
+	"INDX": Indx,
96
+	"MINR": Minr,
97
+	"PEER": Peer,
98
+	"RPCS": Rpcs,
99
+	"SCRP": Scrp,
100
+	"SRVR": Srvr,
101
+	"SYNC": Sync,
102
+	"TXMP": Txmp,
103 103
 }
104 104
 
105
-// InitLogRotator initializes the logging rotater to write logs to logFile and
105
+// InitRotator initializes the logging rotater to write logs to logFile and
106 106
 // create roll files in the same directory.  It must be called before the
107 107
 // package-global log rotater variables are used.
108
-func InitLogRotator(logFile string) {
108
+func InitRotator(logFile string) {
109 109
 	logDir, _ := filepath.Split(logFile)
110 110
 	err := os.MkdirAll(logDir, 0700)
111 111
 	if err != nil {
@@ -118,7 +118,7 @@ func InitLogRotator(logFile string) {
118 118
 		os.Exit(1)
119 119
 	}
120 120
 
121
-	LogRotator = r
121
+	Rotator = r
122 122
 }
123 123
 
124 124
 // SetLogLevel sets the logging level for provided subsystem.  Invalid

btcd/main.go → node/main.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"net"
@@ -7,14 +7,16 @@ import (
7 7
 	"runtime/pprof"
8 8
 
9 9
 	"git.parallelcoin.io/dev/btcd/blockchain/indexers"
10
-	"git.parallelcoin.io/dev/btcd/btcd/version"
10
+	"git.parallelcoin.io/dev/btcd/node/log"
11
+	"git.parallelcoin.io/dev/btcd/node/upgrade"
12
+	"git.parallelcoin.io/dev/btcd/node/version"
11 13
 )
12 14
 
13
-// Main is the real main function for btcd.  It is necessary to work around
14
-// the fact that deferred functions do not run when os.Exit() is called.  The
15
-// optional serverChan parameter is mainly used by the service code to be
16
-// notified with the server once it is setup so it can gracefully stop it when
17
-// requested from the service control manager.
15
+// WinServiceMain is only invoked on Windows.  It detects when node is running
16
+// as a service and reacts accordingly.
17
+var WinServiceMain func() (bool, error)
18
+
19
+// Main is the entrypoint for the node. This is separated so the node can be part of another application and not just standalone as it was originally written
18 20
 func Main(serverChan chan<- *Server) error {
19 21
 	// Load configuration and parse command line.  This function also
20 22
 	// initializes logging and configures it accordingly.
@@ -23,8 +25,8 @@ func Main(serverChan chan<- *Server) error {
23 25
 		return err
24 26
 	}
25 27
 	defer func() {
26
-		if LogRotator != nil {
27
-			LogRotator.Close()
28
+		if log.Rotator != nil {
29
+			log.Rotator.Close()
28 30
 		}
29 31
 	}()
30 32
 
@@ -32,20 +34,20 @@ func Main(serverChan chan<- *Server) error {
32 34
 	// triggered either from an OS signal such as SIGINT (Ctrl+C) or from
33 35
 	// another subsystem such as the RPC server.
34 36
 	interrupt := InterruptListener()
35
-	defer BtcdLog.Info("Shutdown complete")
37
+	defer log.Btcd.Info("Shutdown complete")
36 38
 
37 39
 	// Show version at startup.
38
-	BtcdLog.Infof("Version %s", version.Info())
40
+	log.Btcd.Infof("Version %s", version.Info())
39 41
 
40 42
 	// Enable http profiling server if requested.
41 43
 	if cfg.Profile != "" {
42 44
 		go func() {
43 45
 			listenAddr := net.JoinHostPort("", cfg.Profile)
44
-			BtcdLog.Infof("Profile server listening on %s", listenAddr)
46
+			log.Btcd.Infof("Profile server listening on %s", listenAddr)
45 47
 			profileRedirect := http.RedirectHandler("/debug/pprof",
46 48
 				http.StatusSeeOther)
47 49
 			http.Handle("/", profileRedirect)
48
-			BtcdLog.Errorf("%v", http.ListenAndServe(listenAddr, nil))
50
+			log.Btcd.Errorf("%v", http.ListenAndServe(listenAddr, nil))
49 51
 		}()
50 52
 	}
51 53
 
@@ -53,7 +55,7 @@ func Main(serverChan chan<- *Server) error {
53 55
 	if cfg.CPUProfile != "" {
54 56
 		f, err := os.Create(cfg.CPUProfile)
55 57
 		if err != nil {
56
-			BtcdLog.Errorf("Unable to create cpu profile: %v", err)
58
+			log.Btcd.Errorf("Unable to create cpu profile: %v", err)
57 59
 			return err
58 60
 		}
59 61
 		pprof.StartCPUProfile(f)
@@ -62,8 +64,8 @@ func Main(serverChan chan<- *Server) error {
62 64
 	}
63 65
 
64 66
 	// Perform upgrades to btcd as new versions require it.
65
-	if err := doUpgrades(cfg); err != nil {
66
-		BtcdLog.Errorf("%v", err)
67
+	if err := upgrade.Do(cfg); err != nil {
68
+		log.Btcd.Errorf("%v", err)
67 69
 		return err
68 70
 	}
69 71
 
@@ -75,12 +77,12 @@ func Main(serverChan chan<- *Server) error {
75 77
 	// Load the block database.
76 78
 	db, err := LoadBlockDB(cfg)
77 79
 	if err != nil {
78
-		BtcdLog.Errorf("%v", err)
80
+		log.Btcd.Errorf("%v", err)
79 81
 		return err
80 82
 	}
81 83
 	defer func() {
82 84
 		// Ensure the database is sync'd and closed on shutdown.
83
-		BtcdLog.Infof("Gracefully shutting down the database...")
85
+		log.Btcd.Infof("Gracefully shutting down the database...")
84 86
 		db.Close()
85 87
 	}()
86 88
 
@@ -95,7 +97,7 @@ func Main(serverChan chan<- *Server) error {
95 97
 	// drops the address index since it relies on it.
96 98
 	if cfg.DropAddrIndex {
97 99
 		if err := indexers.DropAddrIndex(db, interrupt); err != nil {
98
-			BtcdLog.Errorf("%v", err)
100
+			log.Btcd.Errorf("%v", err)
99 101
 			return err
100 102
 		}
101 103
 
@@ -103,7 +105,7 @@ func Main(serverChan chan<- *Server) error {
103 105
 	}
104 106
 	if cfg.DropTxIndex {
105 107
 		if err := indexers.DropTxIndex(db, interrupt); err != nil {
106
-			BtcdLog.Errorf("%v", err)
108
+			log.Btcd.Errorf("%v", err)
107 109
 			return err
108 110
 		}
109 111
 
@@ -111,7 +113,7 @@ func Main(serverChan chan<- *Server) error {
111 113
 	}
112 114
 	if cfg.DropCfIndex {
113 115
 		if err := indexers.DropCfIndex(db, interrupt); err != nil {
114
-			BtcdLog.Errorf("%v", err)
116
+			log.Btcd.Errorf("%v", err)
115 117
 			return err
116 118
 		}
117 119
 
@@ -123,15 +125,15 @@ func Main(serverChan chan<- *Server) error {
123 125
 		cfg.AgentWhitelist, db, cfg.StateActiveNet.Params, interrupt)
124 126
 	if err != nil {
125 127
 		// TODO: this logging could do with some beautifying.
126
-		BtcdLog.Errorf("Unable to start server on %v: %v",
128
+		log.Btcd.Errorf("Unable to start server on %v: %v",
127 129
 			cfg.Listeners, err)
128 130
 		return err
129 131
 	}
130 132
 	defer func() {
131
-		BtcdLog.Infof("Gracefully shutting down the server...")
133
+		log.Btcd.Infof("Gracefully shutting down the server...")
132 134
 		server.Stop(cfg)
133 135
 		server.WaitForShutdown()
134
-		SrvrLog.Infof("Server shutdown complete")
136
+		log.Srvr.Infof("Server shutdown complete")
135 137
 	}()
136 138
 	server.Start(cfg)
137 139
 	if serverChan != nil {

btcd/nettype/params.go → node/nettype/params.go View File


btcd/onion/onionaddr.go → node/onion/onionaddr.go View File


btcd/peerstate.go → node/peerstate.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import "time"
4 4
 

btcd/rescan/keys.go → node/rescan/keys.go View File


btcd/rpcconnmgr.go → node/rpcconnmgr.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"git.parallelcoin.io/dev/btcd/mempool"

btcd/rpcerror.go → node/rpcerror.go View File

@@ -1,8 +1,9 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"fmt"
5 5
 
6
+	"git.parallelcoin.io/dev/btcd/node/log"
6 7
 	"git.parallelcoin.io/dev/btcd/btcjson"
7 8
 	"git.parallelcoin.io/dev/btcd/chaincfg/chainhash"
8 9
 )
@@ -17,7 +18,7 @@ func InternalRPCError(errStr, context string) *btcjson.RPCError {
17 18
 	if context != "" {
18 19
 		logStr = context + ": " + errStr
19 20
 	}
20
-	RpcsLog.Error(logStr)
21
+	log.Rpcs.Error(logStr)
21 22
 	return btcjson.NewRPCError(btcjson.ErrRPCInternal.Code, errStr)
22 23
 }
23 24
 

btcd/rpchandlers.go → node/rpchandlers.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"bytes"
@@ -13,7 +13,8 @@ import (
13 13
 	"time"
14 14
 
15 15
 	"git.parallelcoin.io/dev/btcd/blockchain"
16
-	"git.parallelcoin.io/dev/btcd/btcd/version"
16
+	"git.parallelcoin.io/dev/btcd/node/log"
17
+	"git.parallelcoin.io/dev/btcd/node/version"
17 18
 	"git.parallelcoin.io/dev/btcd/btcec"
18 19
 	"git.parallelcoin.io/dev/btcd/btcjson"
19 20
 	"git.parallelcoin.io/dev/btcd/btcutil"
@@ -288,10 +289,10 @@ func HandleDebugLevel(s *RPCServer, cmd interface{}, closeChan <-chan struct{})
288 289
 	// Special show command to list supported subsystems.
289 290
 	if c.LevelSpec == "show" {
290 291
 		return fmt.Sprintf("Supported subsystems %v",
291
-			SupportedSubsystems()), nil
292
+			log.SupportedSubsystems()), nil
292 293
 	}
293 294
 
294
-	err := ParseAndSetDebugLevels(c.LevelSpec)
295
+	err := log.ParseAndSetDebugLevels(c.LevelSpec)
295 296
 	if err != nil {
296 297
 		return nil, &btcjson.RPCError{
297 298
 			Code:    btcjson.ErrRPCInvalidParams.Code,
@@ -539,7 +540,7 @@ func HandleGetAddedNodeInfo(s *RPCServer, cmd interface{}, closeChan <-chan stru
539 540
 			addr.Address = ip
540 541
 			addr.Connected = "false"
541 542
 			if ip == host && peer.Connected() {
542
-				addr.Connected = DirectionString(peer.Inbound())
543
+				addr.Connected = log.DirectionString(peer.Inbound())
543 544
 			}
544 545
 			addrs = append(addrs, addr)
545 546
 		}
@@ -1097,14 +1098,14 @@ func HandleGetBlockTemplateProposal(s *RPCServer, request *btcjson.TemplateReque
1097 1098
 	if err := s.cfg.Chain.CheckConnectBlockTemplate(block); err != nil {
1098 1099
 		if _, ok := err.(blockchain.RuleError); !ok {
1099 1100
 			errStr := fmt.Sprintf("Failed to process block proposal: %v", err)
1100
-			RpcsLog.Error(errStr)
1101
+			log.Rpcs.Error(errStr)
1101 1102
 			return nil, &btcjson.RPCError{
1102 1103
 				Code:    btcjson.ErrRPCVerify,
1103 1104
 				Message: errStr,
1104 1105
 			}
1105 1106
 		}
1106 1107
 
1107
-		RpcsLog.Infof("Rejected block proposal: %v", err)
1108
+		log.Rpcs.Infof("Rejected block proposal: %v", err)
1108 1109
 		return ChainErrToGBTErrString(err), nil
1109 1110
 	}
1110 1111
 
@@ -1155,7 +1156,7 @@ func HandleGetCFilter(s *RPCServer, cmd interface{}, closeChan <-chan struct{})
1155 1156
 
1156 1157
 	filterBytes, err := s.cfg.CfIndex.FilterByBlockHash(hash, c.FilterType)
1157 1158
 	if err != nil {
1158
-		RpcsLog.Debugf("Could not find committed filter for %v: %v",
1159
+		log.Rpcs.Debugf("Could not find committed filter for %v: %v",
1159 1160
 			hash, err)
1160 1161
 		return nil, &btcjson.RPCError{
1161 1162
 			Code:    btcjson.ErrRPCBlockNotFound,
@@ -1163,7 +1164,7 @@ func HandleGetCFilter(s *RPCServer, cmd interface{}, closeChan <-chan struct{})
1163 1164
 		}
1164 1165
 	}
1165 1166
 
1166
-	RpcsLog.Debugf("Found committed filter for %v", hash)
1167
+	log.Rpcs.Debugf("Found committed filter for %v", hash)
1167 1168
 	return hex.EncodeToString(filterBytes), nil
1168 1169
 }
1169 1170
 
@@ -1184,9 +1185,9 @@ func HandleGetCFilterHeader(s *RPCServer, cmd interface{}, closeChan <-chan stru
1184 1185
 
1185 1186
 	headerBytes, err := s.cfg.CfIndex.FilterHeaderByBlockHash(hash, c.FilterType)
1186 1187
 	if len(headerBytes) > 0 {
1187
-		RpcsLog.Debugf("Found header of committed filter for %v", hash)
1188
+		log.Rpcs.Debugf("Found header of committed filter for %v", hash)
1188 1189
 	} else {
1189
-		RpcsLog.Debugf("Could not find header of committed filter for %v: %v",
1190
+		log.Rpcs.Debugf("Could not find header of committed filter for %v: %v",
1190 1191
 			hash, err)
1191 1192
 		return nil, &btcjson.RPCError{
1192 1193
 			Code:    btcjson.ErrRPCBlockNotFound,
@@ -1394,7 +1395,7 @@ func HandleGetNetworkHashPS(s *RPCServer, cmd interface{}, closeChan <-chan stru
1394 1395
 	if startHeight < 0 {
1395 1396
 		startHeight = 0
1396 1397
 	}
1397
-	RpcsLog.Debugf("Calculating network hashes per second from %d to %d",
1398
+	log.Rpcs.Debugf("Calculating network hashes per second from %d to %d",
1398 1399
 		startHeight, endHeight)
1399 1400
 
1400 1401
 	// Find the min and max block timestamps as well as calculate the total
@@ -2073,7 +2074,7 @@ func HandleSendRawTransaction(s *RPCServer, cmd interface{}, closeChan <-chan st
2073 2074
 		// so log it as an actual error and return.
2074 2075
 		ruleErr, ok := err.(mempool.RuleError)
2075 2076
 		if !ok {
2076
-			RpcsLog.Errorf("Failed to process transaction %v: %v",
2077
+			log.Rpcs.Errorf("Failed to process transaction %v: %v",
2077 2078
 				tx.Hash(), err)
2078 2079
 
2079 2080
 			return nil, &btcjson.RPCError{
@@ -2082,7 +2083,7 @@ func HandleSendRawTransaction(s *RPCServer, cmd interface{}, closeChan <-chan st
2082 2083
 			}
2083 2084
 		}
2084 2085
 
2085
-		RpcsLog.Debugf("Rejected transaction %v: %v", tx.Hash(), err)
2086
+		log.Rpcs.Debugf("Rejected transaction %v: %v", tx.Hash(), err)
2086 2087
 
2087 2088
 		// We'll then map the rule error to the appropriate RPC error,
2088 2089
 		// matching bitcoind's behavior.
@@ -2218,7 +2219,7 @@ func HandleSubmitBlock(s *RPCServer, cmd interface{}, closeChan <-chan struct{})
2218 2219
 		return fmt.Sprintf("rejected: %s", err.Error()), nil
2219 2220
 	}
2220 2221
 
2221
-	RpcsLog.Infof("Accepted block %s via submitblock", block.Hash())
2222
+	log.Rpcs.Infof("Accepted block %s via submitblock", block.Hash())
2222 2223
 	return nil, nil
2223 2224
 }
2224 2225
 

btcd/rpchelpcacher.go → node/rpchelpcacher.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"errors"

btcd/rpcparsecmd.go → node/rpcparsecmd.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import "git.parallelcoin.io/dev/btcd/btcjson"
4 4
 

btcd/rpcpeer.go → node/rpcpeer.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"sync/atomic"

btcd/rpcserve.go → node/rpcserve.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"bytes"
@@ -13,6 +13,7 @@ import (
13 13
 	"time"
14 14
 
15 15
 	"git.parallelcoin.io/dev/btcd/blockchain"
16
+	"git.parallelcoin.io/dev/btcd/node/log"
16 17
 	"git.parallelcoin.io/dev/btcd/btcjson"
17 18
 	"git.parallelcoin.io/dev/btcd/btcutil"
18 19
 	"git.parallelcoin.io/dev/btcd/chaincfg"
@@ -362,7 +363,7 @@ func GetDifficultyRatio(bits uint32, params *chaincfg.Params) float64 {
362 363
 	outString := difficulty.FloatString(8)
363 364
 	diff, err := strconv.ParseFloat(outString, 64)
364 365
 	if err != nil {
365
-		RpcsLog.Errorf("Cannot get difficulty: %v", err)
366
+		log.Rpcs.Errorf("Cannot get difficulty: %v", err)
366 367
 		return 0
367 368
 	}
368 369
 	return diff
@@ -551,14 +552,14 @@ func VerifyChain(s *RPCServer, level, depth int32) error {
551 552
 	if finishHeight < 0 {
552 553
 		finishHeight = 0
553 554
 	}
554
-	RpcsLog.Infof("Verifying chain for %d blocks at level %d",
555
+	log.Rpcs.Infof("Verifying chain for %d blocks at level %d",
555 556
 		best.Height-finishHeight, level)
556 557
 
557 558
 	for height := best.Height; height > finishHeight; height-- {
558 559
 		// Level 0 just looks up the block.
559 560
 		block, err := s.cfg.Chain.BlockByHeight(height)
560 561
 		if err != nil {
561
-			RpcsLog.Errorf("Verify is unable to fetch block at "+
562
+			log.Rpcs.Errorf("Verify is unable to fetch block at "+
562 563
 				"height %d: %v", height, err)
563 564
 			return err
564 565
 		}
@@ -568,14 +569,14 @@ func VerifyChain(s *RPCServer, level, depth int32) error {
568 569
 			err := blockchain.CheckBlockSanity(block,
569 570
 				s.cfg.ChainParams.PowLimit, s.cfg.TimeSource)
570 571
 			if err != nil {
571
-				RpcsLog.Errorf("Verify is unable to validate "+
572
+				log.Rpcs.Errorf("Verify is unable to validate "+
572 573
 					"block at hash %v height %d: %v",
573 574
 					block.Hash(), height, err)
574 575
 				return err
575 576
 			}
576 577
 		}
577 578
 	}
578
-	RpcsLog.Infof("Chain verify completed successfully")
579
+	log.Rpcs.Infof("Chain verify completed successfully")
579 580
 
580 581
 	return nil
581 582
 }
@@ -812,7 +813,7 @@ func CreateMarshalledReply(id, result interface{}, replyErr error) ([]byte, erro
812 813
 
813 814
 // GenCertPair generates a key/cert pair to the paths provided.
814 815
 func GenCertPair(certFile, keyFile string) error {
815
-	RpcsLog.Infof("Generating TLS certificates...")
816
+	log.Rpcs.Infof("Generating TLS certificates...")
816 817
 
817 818
 	org := "btcd autogenerated cert"
818 819
 	validUntil := time.Now().Add(10 * 365 * 24 * time.Hour)
@@ -830,7 +831,7 @@ func GenCertPair(certFile, keyFile string) error {
830 831
 		return err
831 832
 	}
832 833
 
833
-	RpcsLog.Infof("Done generating TLS certificates")
834
+	log.Rpcs.Infof("Done generating TLS certificates")
834 835
 	return nil
835 836
 }
836 837
 

btcd/rpcserver.go → node/rpcserver.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"crypto/sha256"
@@ -17,7 +17,8 @@ import (
17 17
 	"time"
18 18
 
19 19
 	"git.parallelcoin.io/dev/btcd/blockchain"
20
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
20
+	"git.parallelcoin.io/dev/btcd/node/cnf"
21
+	"git.parallelcoin.io/dev/btcd/node/log"
21 22
 	"git.parallelcoin.io/dev/btcd/btcjson"
22 23
 	"git.parallelcoin.io/dev/btcd/btcutil"
23 24
 	"git.parallelcoin.io/dev/btcd/mempool"
@@ -127,14 +128,14 @@ func (s *RPCServer) WriteHTTPResponseHeaders(req *http.Request, headers http.Hea
127 128
 // Stop is used by server.go to stop the rpc listener.
128 129
 func (s *RPCServer) Stop() error {
129 130
 	if atomic.AddInt32(&s.shutdown, 1) != 1 {
130
-		RpcsLog.Infof("RPC server is already in the process of shutting down")
131
+		log.Rpcs.Infof("RPC server is already in the process of shutting down")
131 132
 		return nil
132 133
 	}
133
-	RpcsLog.Warnf("RPC server shutting down")
134
+	log.Rpcs.Warnf("RPC server shutting down")
134 135
 	for _, listener := range s.cfg.Listeners {
135 136
 		err := listener.Close()
136 137
 		if err != nil {
137
-			RpcsLog.Errorf("Problem shutting down rpc: %v", err)
138
+			log.Rpcs.Errorf("Problem shutting down rpc: %v", err)
138 139
 			return err
139 140
 		}
140 141
 	}
@@ -142,7 +143,7 @@ func (s *RPCServer) Stop() error {
142 143
 	s.ntfnMgr.WaitForShutdown()
143 144
 	close(s.quit)
144 145
 	s.WG.Wait()
145
-	RpcsLog.Infof("RPC server shutdown complete")
146
+	log.Rpcs.Infof("RPC server shutdown complete")
146 147
 	return nil
147 148
 }
148 149
 
@@ -173,7 +174,7 @@ func (s *RPCServer) NotifyNewTransactions(txns []*mempool.TxDesc) {
173 174
 // This function is safe for concurrent access.
174 175
 func (s *RPCServer) LimitConnections(w http.ResponseWriter, remoteAddr string) bool {
175 176
 	if int(atomic.LoadInt32(&s.numClients)+1) > s.config.RPCMaxClients {
176
-		RpcsLog.Infof("Max RPC clients exceeded [%d] - "+
177
+		log.Rpcs.Infof("Max RPC clients exceeded [%d] - "+
177 178
 			"disconnecting client %s", s.config.RPCMaxClients,
178 179
 			remoteAddr)
179 180
 		http.Error(w, "503 Too busy.  Try again later.",
@@ -216,7 +217,7 @@ func (s *RPCServer) CheckAuth(r *http.Request, require bool) (bool, bool, error)
216 217
 	authhdr := r.Header["Authorization"]
217 218
 	if len(authhdr) <= 0 {
218 219
 		if require {
219
-			RpcsLog.Warnf("RPC authentication failure from %s",
220
+			log.Rpcs.Warnf("RPC authentication failure from %s",
220 221
 				r.RemoteAddr)
221 222
 			return false, false, errors.New("auth failure")
222 223
 		}
@@ -240,7 +241,7 @@ func (s *RPCServer) CheckAuth(r *http.Request, require bool) (bool, bool, error)
240 241
 	}
241 242
 
242 243
 	// Request's auth doesn't match either user
243
-	RpcsLog.Warnf("RPC authentication failure from %s", r.RemoteAddr)
244
+	log.Rpcs.Warnf("RPC authentication failure from %s", r.RemoteAddr)
244 245
 	return false, false, errors.New("auth failure")
245 246
 }
246 247
 
@@ -294,14 +295,14 @@ func (s *RPCServer) JSONRPCRead(w http.ResponseWriter, r *http.Request, isAdmin
294 295
 	hj, ok := w.(http.Hijacker)
295 296
 	if !ok {
296 297
 		errMsg := "webserver doesn't support hijacking"
297
-		RpcsLog.Warnf(errMsg)
298
+		log.Rpcs.Warnf(errMsg)
298 299
 		errCode := http.StatusInternalServerError
299 300
 		http.Error(w, strconv.Itoa(errCode)+" "+errMsg, errCode)
300 301
 		return
301 302
 	}
302 303
 	conn, buf, err := hj.Hijack()
303 304
 	if err != nil {
304
-		RpcsLog.Warnf("Failed to hijack HTTP connection: %v", err)
305
+		log.Rpcs.Warnf("Failed to hijack HTTP connection: %v", err)
305 306
 		errCode := http.StatusInternalServerError
306 307
 		http.Error(w, strconv.Itoa(errCode)+" "+err.Error(), errCode)
307 308
 		return
@@ -383,23 +384,23 @@ func (s *RPCServer) JSONRPCRead(w http.ResponseWriter, r *http.Request, isAdmin
383 384
 	// Marshal the response.
384 385
 	msg, err := CreateMarshalledReply(responseID, result, jsonErr)
385 386
 	if err != nil {
386
-		RpcsLog.Errorf("Failed to marshal reply: %v", err)
387
+		log.Rpcs.Errorf("Failed to marshal reply: %v", err)
387 388
 		return
388 389
 	}
389 390
 
390 391
 	// Write the response.
391 392
 	err = s.WriteHTTPResponseHeaders(r, w.Header(), http.StatusOK, buf)
392 393
 	if err != nil {
393
-		RpcsLog.Error(err)
394
+		log.Rpcs.Error(err)
394 395
 		return
395 396
 	}
396 397
 	if _, err := buf.Write(msg); err != nil {
397
-		RpcsLog.Errorf("Failed to write marshalled reply: %v", err)
398
+		log.Rpcs.Errorf("Failed to write marshalled reply: %v", err)
398 399
 	}
399 400
 
400 401
 	// Terminate with newline to maintain compatibility with Bitcoin Core.
401 402
 	if err := buf.WriteByte('\n'); err != nil {
402
-		RpcsLog.Errorf("Failed to append terminating newline to reply: %v", err)
403
+		log.Rpcs.Errorf("Failed to append terminating newline to reply: %v", err)
403 404
 	}
404 405
 }
405 406
 
@@ -409,7 +410,7 @@ func (s *RPCServer) Start() {
409 410
 		return
410 411
 	}
411 412
 
412
-	RpcsLog.Trace("Starting RPC server")
413
+	log.Rpcs.Trace("Starting RPC server")
413 414
 	rpcServeMux := http.NewServeMux()
414 415
 	httpServer := &http.Server{
415 416
 		Handler: rpcServeMux,
@@ -454,7 +455,7 @@ func (s *RPCServer) Start() {
454 455
 		ws, err := websocket.Upgrade(w, r, nil, 0, 0)
455 456
 		if err != nil {
456 457
 			if _, ok := err.(websocket.HandshakeError); !ok {
457
-				RpcsLog.Errorf("Unexpected websocket error: %v",
458
+				log.Rpcs.Errorf("Unexpected websocket error: %v",
458 459
 					err)
459 460
 			}
460 461
 			http.Error(w, "400 Bad Request.", http.StatusBadRequest)
@@ -466,9 +467,9 @@ func (s *RPCServer) Start() {
466 467
 	for _, listener := range s.cfg.Listeners {
467 468
 		s.WG.Add(1)
468 469
 		go func(listener net.Listener) {
469
-			RpcsLog.Infof("RPC server listening on %s", listener.Addr())
470
+			log.Rpcs.Infof("RPC server listening on %s", listener.Addr())
470 471
 			httpServer.Serve(listener)
471
-			RpcsLog.Tracef("RPC listener done for %s", listener.Addr())
472
+			log.Rpcs.Tracef("RPC listener done for %s", listener.Addr())
472 473
 			s.WG.Done()
473 474
 		}(listener)
474 475
 	}
@@ -484,7 +485,7 @@ func (s *RPCServer) HandleBlockchainNotification(notification *blockchain.Notifi
484 485
 	case blockchain.NTBlockAccepted:
485 486
 		block, ok := notification.Data.(*btcutil.Block)
486 487
 		if !ok {
487
-			RpcsLog.Warnf("Chain accepted notification is not a block.")
488
+			log.Rpcs.Warnf("Chain accepted notification is not a block.")
488 489
 			break
489 490
 		}
490 491
 
@@ -496,7 +497,7 @@ func (s *RPCServer) HandleBlockchainNotification(notification *blockchain.Notifi
496 497
 	case blockchain.NTBlockConnected:
497 498
 		block, ok := notification.Data.(*btcutil.Block)
498 499
 		if !ok {
499
-			RpcsLog.Warnf("Chain connected notification is not a block.")
500
+			log.Rpcs.Warnf("Chain connected notification is not a block.")
500 501
 			break
501 502
 		}
502 503
 
@@ -506,7 +507,7 @@ func (s *RPCServer) HandleBlockchainNotification(notification *blockchain.Notifi
506 507
 	case blockchain.NTBlockDisconnected:
507 508
 		block, ok := notification.Data.(*btcutil.Block)
508 509
 		if !ok {
509
-			RpcsLog.Warnf("Chain disconnected notification is not a block.")
510
+			log.Rpcs.Warnf("Chain disconnected notification is not a block.")
510 511
 			break
511 512
 		}
512 513
 
@@ -527,9 +528,9 @@ func (s *RPCServer) WebsocketHandler(cfg *cnf.Config, conn *websocket.Conn, remo
527 528
 	conn.SetReadDeadline(TimeZeroVal)
528 529
 
529 530
 	// Limit max number of websocket clients.
530
-	RpcsLog.Infof("New websocket client %s", remoteAddr)
531
+	log.Rpcs.Infof("New websocket client %s", remoteAddr)
531 532
 	if s.ntfnMgr.GetNumClients()+1 > cfg.RPCMaxWebsockets {
532
-		RpcsLog.Infof("Max websocket clients exceeded [%d] - "+
533
+		log.Rpcs.Infof("Max websocket clients exceeded [%d] - "+
533 534
 			"disconnecting client %s", cfg.RPCMaxWebsockets,
534 535
 			remoteAddr)
535 536
 		conn.Close()
@@ -541,7 +542,7 @@ func (s *RPCServer) WebsocketHandler(cfg *cnf.Config, conn *websocket.Conn, remo
541 542
 	// disconnected), remove it and any notifications it registered for.
542 543
 	client, err := NewWebsocketClient(s, conn, remoteAddr, authenticated, isAdmin)
543 544
 	if err != nil {
544
-		RpcsLog.Errorf("Failed to serve client %s: %v", remoteAddr, err)
545
+		log.Rpcs.Errorf("Failed to serve client %s: %v", remoteAddr, err)
545 546
 		conn.Close()
546 547
 		return
547 548
 	}
@@ -549,5 +550,5 @@ func (s *RPCServer) WebsocketHandler(cfg *cnf.Config, conn *websocket.Conn, remo
549 550
 	client.Start(cfg)
550 551
 	client.WaitForShutdown()
551 552
 	s.ntfnMgr.RemoveClient(client)
552
-	RpcsLog.Infof("Disconnected websocket client %s", remoteAddr)
553
+	log.Rpcs.Infof("Disconnected websocket client %s", remoteAddr)
553 554
 }

btcd/rpcserverconfig.go → node/rpcserverconfig.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"net"

btcd/rpcserverconnmanager.go → node/rpcserverconnmanager.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"git.parallelcoin.io/dev/btcd/mempool"

btcd/rpcserverhelp.go → node/rpcserverhelp.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"git.parallelcoin.io/dev/btcd/btcjson"

btcd/rpcserverpeer.go → node/rpcserverpeer.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import "git.parallelcoin.io/dev/btcd/peer"
4 4
 

btcd/rpcserversyncmanager.go → node/rpcserversyncmanager.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"git.parallelcoin.io/dev/btcd/blockchain"

btcd/rpcsyncmgr.go → node/rpcsyncmgr.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"git.parallelcoin.io/dev/btcd/blockchain"

btcd/rpcwebsocket.go → node/rpcwebsocket.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"bytes"
@@ -9,7 +9,8 @@ import (
9 9
 	"time"
10 10
 
11 11
 	"git.parallelcoin.io/dev/btcd/blockchain"
12
-	"git.parallelcoin.io/dev/btcd/btcd/rescan"
12
+	"git.parallelcoin.io/dev/btcd/node/log"
13
+	"git.parallelcoin.io/dev/btcd/node/rescan"
13 14
 	"git.parallelcoin.io/dev/btcd/btcjson"
14 15
 	"git.parallelcoin.io/dev/btcd/btcutil"
15 16
 	"git.parallelcoin.io/dev/btcd/chaincfg"
@@ -423,7 +424,7 @@ func RescanBlock(wsc *WSClient, lookups *rescan.Keys, blk *btcutil.Block) {
423 424
 					return
424 425
 				}
425 426
 				if err != nil {
426
-					RpcsLog.Errorf("Unable to notify "+
427
+					log.Rpcs.Errorf("Unable to notify "+
427 428
 						"redeeming transaction %v: %v",
428 429
 						tx.Hash(), err)
429 430
 					continue
@@ -461,7 +462,7 @@ func RescanBlock(wsc *WSClient, lookups *rescan.Keys, blk *btcutil.Block) {
461 462
 					return
462 463
 				}
463 464
 				if err != nil {
464
-					RpcsLog.Errorf("Unable to notify "+
465
+					log.Rpcs.Errorf("Unable to notify "+
465 466
 						"redeeming transaction %v: %v",
466 467
 						tx.Hash(), err)
467 468
 					continue
@@ -498,7 +499,7 @@ func RescanBlock(wsc *WSClient, lookups *rescan.Keys, blk *btcutil.Block) {
498 499
 
499 500
 				marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
500 501
 				if err != nil {
501
-					RpcsLog.Errorf("Failed to marshal recvtx notification: %v", err)
502
+					log.Rpcs.Errorf("Failed to marshal recvtx notification: %v", err)
502 503
 					return
503 504
 				}
504 505
 
@@ -654,7 +655,7 @@ func RecoverFromReorg(chain *blockchain.BlockChain, minBlock, maxBlock int32,
654 655
 
655 656
 	hashList, err := chain.HeightRange(minBlock, maxBlock)
656 657
 	if err != nil {
657
-		RpcsLog.Errorf("Error looking up block range: %v", err)
658
+		log.Rpcs.Errorf("Error looking up block range: %v", err)
658 659
 		return nil, &btcjson.RPCError{
659 660
 			Code:    btcjson.ErrRPCDatabase,
660 661
 			Message: "Database error: " + err.Error(),
@@ -666,7 +667,7 @@ func RecoverFromReorg(chain *blockchain.BlockChain, minBlock, maxBlock int32,
666 667
 
667 668
 	blk, err := chain.BlockByHash(&hashList[0])
668 669
 	if err != nil {
669
-		RpcsLog.Errorf("Error looking up possibly reorged block: %v",
670
+		log.Rpcs.Errorf("Error looking up possibly reorged block: %v",
670 671
 			err)
671 672
 		return nil, &btcjson.RPCError{
672 673
 			Code:    btcjson.ErrRPCDatabase,
@@ -685,7 +686,7 @@ func RecoverFromReorg(chain *blockchain.BlockChain, minBlock, maxBlock int32,
685 686
 func DescendantBlock(prevHash *chainhash.Hash, curBlock *btcutil.Block) error {
686 687
 	curHash := &curBlock.MsgBlock().Header.PrevBlock
687 688
 	if !prevHash.IsEqual(curHash) {
688
-		RpcsLog.Errorf("Stopping rescan for reorged block %v "+
689
+		log.Rpcs.Errorf("Stopping rescan for reorged block %v "+
689 690
 			"(replaced by block %v)", prevHash, curHash)
690 691
 		return &ErrRescanReorg
691 692
 	}
@@ -727,7 +728,7 @@ fetchRange:
727 728
 		}
728 729
 		hashList, err := chain.HeightRange(minBlock, maxLoopBlock)
729 730
 		if err != nil {
730
-			RpcsLog.Errorf("Error looking up block range: %v", err)
731
+			log.Rpcs.Errorf("Error looking up block range: %v", err)
731 732
 			return nil, nil, &btcjson.RPCError{
732 733
 				Code:    btcjson.ErrRPCDatabase,
733 734
 				Message: "Database error: " + err.Error(),
@@ -765,7 +766,7 @@ fetchRange:
765 766
 			}
766 767
 			close(pauseGuard)
767 768
 			if err != nil {
768
-				RpcsLog.Errorf("Error fetching best block "+
769
+				log.Rpcs.Errorf("Error fetching best block "+
769 770
 					"hash: %v", err)
770 771
 				return nil, nil, &btcjson.RPCError{
771 772
 					Code: btcjson.ErrRPCDatabase,
@@ -788,7 +789,7 @@ fetchRange:
788 789
 				if dbErr, ok := err.(database.Error); !ok ||
789 790
 					dbErr.ErrorCode != database.ErrBlockNotFound {
790 791
 
791
-					RpcsLog.Errorf("Error looking up "+
792
+					log.Rpcs.Errorf("Error looking up "+
792 793
 						"block: %v", err)
793 794
 					return nil, nil, &btcjson.RPCError{
794 795
 						Code: btcjson.ErrRPCDatabase,
@@ -800,7 +801,7 @@ fetchRange:
800 801
 				// If an absolute max block was specified, don't
801 802
 				// attempt to handle the reorg.
802 803
 				if maxBlock != math.MaxInt32 {
803
-					RpcsLog.Errorf("Stopping rescan for "+
804
+					log.Rpcs.Errorf("Stopping rescan for "+
804 805
 						"reorged block %v",
805 806
 						cmd.EndBlock)
806 807
 					return nil, nil, &ErrRescanReorg
@@ -841,7 +842,7 @@ fetchRange:
841 842
 			// client requesting the rescan has disconnected.
842 843
 			select {
843 844
 			case <-wsc.Quit:
844
-				RpcsLog.Debugf("Stopped rescan at height %v "+
845
+				log.Rpcs.Debugf("Stopped rescan at height %v "+
845 846
 					"for disconnected client", blk.Height())
846 847
 				return nil, nil, nil
847 848
 			default:
@@ -865,14 +866,14 @@ fetchRange:
865 866
 			)
866 867
 			mn, err := btcjson.MarshalCmd(nil, n)
867 868
 			if err != nil {
868
-				RpcsLog.Errorf("Failed to marshal rescan "+
869
+				log.Rpcs.Errorf("Failed to marshal rescan "+
869 870
 					"progress notification: %v", err)
870 871
 				continue
871 872
 			}
872 873
 
873 874
 			if err = wsc.QueueNotification(mn); err == ErrClientQuit {
874 875
 				// Finished if the client disconnected.
875
-				RpcsLog.Debugf("Stopped rescan at height %v "+
876
+				log.Rpcs.Debugf("Stopped rescan at height %v "+
876 877
 					"for disconnected client", blk.Height())
877 878
 				return nil, nil, nil
878 879
 			}
@@ -913,9 +914,9 @@ func HandleRescan(wsc *WSClient, icmd interface{}) (interface{}, error) {
913 914
 
914 915
 	numAddrs := len(cmd.Addresses)
915 916
 	if numAddrs == 1 {
916
-		RpcsLog.Info("Beginning rescan for 1 address")
917
+		log.Rpcs.Info("Beginning rescan for 1 address")
917 918
 	} else {
918
-		RpcsLog.Infof("Beginning rescan for %d addresses", numAddrs)
919
+		log.Rpcs.Infof("Beginning rescan for %d addresses", numAddrs)
919 920
 	}
920 921
 
921 922
 	// Build lookup maps.
@@ -974,7 +975,7 @@ func HandleRescan(wsc *WSClient, icmd interface{}) (interface{}, error) {
974 975
 			return nil, err
975 976
 		}
976 977
 	} else {
977
-		RpcsLog.Infof("Skipping rescan as client has no addrs/utxos")
978
+		log.Rpcs.Infof("Skipping rescan as client has no addrs/utxos")
978 979
 
979 980
 		// If we didn't actually do a rescan, then we'll give the
980 981
 		// client our best known block within the final rescan finished
@@ -1002,7 +1003,7 @@ func HandleRescan(wsc *WSClient, icmd interface{}) (interface{}, error) {
1002 1003
 		lastBlock.MsgBlock().Header.Timestamp.Unix(),
1003 1004
 	)
1004 1005
 	if mn, err := btcjson.MarshalCmd(nil, n); err != nil {
1005
-		RpcsLog.Errorf("Failed to marshal rescan finished "+
1006
+		log.Rpcs.Errorf("Failed to marshal rescan finished "+
1006 1007
 			"notification: %v", err)
1007 1008
 	} else {
1008 1009
 		// The rescan is finished, so we don't care whether the client
@@ -1010,7 +1011,7 @@ func HandleRescan(wsc *WSClient, icmd interface{}) (interface{}, error) {
1010 1011
 		_ = wsc.QueueNotification(mn)
1011 1012
 	}
1012 1013
 
1013
-	RpcsLog.Info("Finished rescan")
1014
+	log.Rpcs.Info("Finished rescan")
1014 1015
 	return nil, nil
1015 1016
 }
1016 1017
 

btcd/sample-btcd.conf.go → node/sample-btcd.conf.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 var samplebtcdconf = `[Application Options]
4 4
 

btcd/server.go → node/server.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"bytes"
@@ -21,13 +21,14 @@ import (
21 21
 	"git.parallelcoin.io/dev/btcd/addrmgr/network"
22 22
 	"git.parallelcoin.io/dev/btcd/blockchain"
23 23
 	"git.parallelcoin.io/dev/btcd/blockchain/indexers"
24
-	"git.parallelcoin.io/dev/btcd/btcd/checkpoint"
25
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
26
-	"git.parallelcoin.io/dev/btcd/btcd/defaults"
27
-	"git.parallelcoin.io/dev/btcd/btcd/onion"
28
-	"git.parallelcoin.io/dev/btcd/btcd/simple"
29
-	"git.parallelcoin.io/dev/btcd/btcd/upnp"
30
-	"git.parallelcoin.io/dev/btcd/btcd/version"
24
+	"git.parallelcoin.io/dev/btcd/node/checkpoint"
25
+	"git.parallelcoin.io/dev/btcd/node/cnf"
26
+	"git.parallelcoin.io/dev/btcd/node/defaults"
27
+	"git.parallelcoin.io/dev/btcd/node/log"
28
+	"git.parallelcoin.io/dev/btcd/node/onion"
29
+	"git.parallelcoin.io/dev/btcd/node/simple"
30
+	"git.parallelcoin.io/dev/btcd/node/upnp"
31
+	"git.parallelcoin.io/dev/btcd/node/version"
31 32
 	"git.parallelcoin.io/dev/btcd/btcutil"
32 33
 	"git.parallelcoin.io/dev/btcd/btcutil/bloom"
33 34
 	"git.parallelcoin.io/dev/btcd/chaincfg"
@@ -311,7 +312,7 @@ func (s *Server) PushTxMsg(sp *ServerPeer, hash *chainhash.Hash, doneChan chan<-
311 312
 	// to fetch a missing transaction results in the same behavior.
312 313
 	tx, err := s.TxMemPool.FetchTransaction(hash)
313 314
 	if err != nil {
314
-		PeerLog.Tracef("Unable to fetch tx %v from transaction "+
315
+		log.Peer.Tracef("Unable to fetch tx %v from transaction "+
315 316
 			"pool: %v", hash, err)
316 317
 
317 318
 		if doneChan != nil {
@@ -343,7 +344,7 @@ func (s *Server) PushBlockMsg(sp *ServerPeer, hash *chainhash.Hash, doneChan cha
343 344
 		return err
344 345
 	})
345 346
 	if err != nil {
346
-		PeerLog.Tracef("Unable to fetch requested block hash %v: %v",
347
+		log.Peer.Tracef("Unable to fetch requested block hash %v: %v",
347 348
 			hash, err)
348 349
 
349 350
 		if doneChan != nil {
@@ -356,7 +357,7 @@ func (s *Server) PushBlockMsg(sp *ServerPeer, hash *chainhash.Hash, doneChan cha
356 357
 	var msgBlock wire.MsgBlock
357 358
 	err = msgBlock.Deserialize(bytes.NewReader(blockBytes))
358 359
 	if err != nil {
359
-		PeerLog.Tracef("Unable to deserialize requested block hash "+
360
+		log.Peer.Tracef("Unable to deserialize requested block hash "+
360 361
 			"%v: %v", hash, err)
361 362
 
362 363
 		if doneChan != nil {
@@ -414,7 +415,7 @@ func (s *Server) PushMerkleBlockMsg(sp *ServerPeer, hash *chainhash.Hash,
414 415
 	// Fetch the raw block bytes from the database.
415 416
 	blk, err := sp.Server.Chain.BlockByHash(hash)
416 417
 	if err != nil {
417
-		PeerLog.Tracef("Unable to fetch requested block hash %v: %v",
418
+		log.Peer.Tracef("Unable to fetch requested block hash %v: %v",
418 419
 			hash, err)
419 420
 
420 421
 		if doneChan != nil {
@@ -500,7 +501,7 @@ func (s *Server) HandleAddPeerMsg(cfg *cnf.Config, state *PeerState, sp *ServerP
500 501
 
501 502
 	// Ignore new peers if we're shutting down.
502 503
 	if atomic.LoadInt32(&s.Shutdown) != 0 {
503
-		SrvrLog.Infof("New peer %s ignored - server is shutting down", sp)
504
+		log.Srvr.Infof("New peer %s ignored - server is shutting down", sp)
504 505
 		sp.Disconnect()
505 506
 		return false
506 507
 	}
@@ -508,19 +509,19 @@ func (s *Server) HandleAddPeerMsg(cfg *cnf.Config, state *PeerState, sp *ServerP
508 509
 	// Disconnect banned peers.
509 510
 	host, _, err := net.SplitHostPort(sp.Addr())
510 511
 	if err != nil {
511
-		SrvrLog.Debugf("can't split hostport %v", err)
512
+		log.Srvr.Debugf("can't split hostport %v", err)
512 513
 		sp.Disconnect()
513 514
 		return false
514 515
 	}
515 516
 	if banEnd, ok := state.Banned[host]; ok {
516 517
 		if time.Now().Before(banEnd) {
517
-			SrvrLog.Debugf("Peer %s is banned for another %v - disconnecting",
518
+			log.Srvr.Debugf("Peer %s is banned for another %v - disconnecting",
518 519
 				host, time.Until(banEnd))
519 520
 			sp.Disconnect()
520 521
 			return false
521 522
 		}
522 523
 
523
-		SrvrLog.Infof("Peer %s is no longer banned", host)
524
+		log.Srvr.Infof("Peer %s is no longer banned", host)
524 525
 		delete(state.Banned, host)
525 526
 	}
526 527
 
@@ -528,7 +529,7 @@ func (s *Server) HandleAddPeerMsg(cfg *cnf.Config, state *PeerState, sp *ServerP
528 529
 
529 530
 	// Limit max number of total peers.
530 531
 	if state.Count() >= cfg.MaxPeers {
531
-		SrvrLog.Infof("Max peers reached [%d] - disconnecting peer %s",
532
+		log.Srvr.Infof("Max peers reached [%d] - disconnecting peer %s",
532 533
 			cfg.MaxPeers, sp)
533 534
 		sp.Disconnect()
534 535
 		// TODO: how to handle permanent peers here?
@@ -537,7 +538,7 @@ func (s *Server) HandleAddPeerMsg(cfg *cnf.Config, state *PeerState, sp *ServerP
537 538
 	}
538 539
 
539 540
 	// Add the new peer and start it.
540
-	SrvrLog.Debugf("New peer %s", sp)
541
+	log.Srvr.Debugf("New peer %s", sp)
541 542
 	if sp.Inbound() {
542 543
 		state.InboundPeers[sp.ID()] = sp
543 544
 	} else {
@@ -571,7 +572,7 @@ func (s *Server) HandleDonePeerMsg(state *PeerState, sp *ServerPeer) {
571 572
 			s.ConnManager.Disconnect(sp.ConnReq.ID())
572 573
 		}
573 574
 		delete(list, sp.ID())
574
-		SrvrLog.Debugf("Removed peer %s", sp)
575
+		log.Srvr.Debugf("Removed peer %s", sp)
575 576
 		return
576 577
 	}
577 578
 
@@ -594,11 +595,11 @@ func (s *Server) HandleDonePeerMsg(state *PeerState, sp *ServerPeer) {
594 595
 func (s *Server) HandleBanPeerMsg(cfg *cnf.Config, state *PeerState, sp *ServerPeer) {
595 596
 	host, _, err := net.SplitHostPort(sp.Addr())
596 597
 	if err != nil {
597
-		SrvrLog.Debugf("can't split ban peer %s %v", sp.Addr(), err)
598
+		log.Srvr.Debugf("can't split ban peer %s %v", sp.Addr(), err)
598 599
 		return
599 600
 	}
600
-	direction := DirectionString(sp.Inbound())
601
-	SrvrLog.Infof("Banned peer %s (%s) for %v", host, direction,
601
+	direction := log.DirectionString(sp.Inbound())
602
+	log.Srvr.Infof("Banned peer %s (%s) for %v", host, direction,
602 603
 		cfg.BanDuration)
603 604
 	state.Banned[host] = time.Now().Add(cfg.BanDuration)
604 605
 }
@@ -617,13 +618,13 @@ func (s *Server) HandleRelayInvMsg(state *PeerState, msg RelayMsg) {
617 618
 		if msg.InvVect.Type == wire.InvTypeBlock && sp.WantsHeaders() {
618 619
 			blockHeader, ok := msg.Data.(wire.BlockHeader)
619 620
 			if !ok {
620
-				PeerLog.Warnf("Underlying data for headers" +
621
+				log.Peer.Warnf("Underlying data for headers" +
621 622
 					" is not a block header")
622 623
 				return
623 624
 			}
624 625
 			msgHeaders := wire.NewMsgHeaders()
625 626
 			if err := msgHeaders.AddBlockHeader(&blockHeader); err != nil {
626
-				PeerLog.Errorf("Failed to add block"+
627
+				log.Peer.Errorf("Failed to add block"+
627 628
 					" header: %v", err)
628 629
 				return
629 630
 			}
@@ -640,7 +641,7 @@ func (s *Server) HandleRelayInvMsg(state *PeerState, msg RelayMsg) {
640 641
 
641 642
 			txD, ok := msg.Data.(*mempool.TxDesc)
642 643
 			if !ok {
643
-				PeerLog.Warnf("Underlying data for tx inv "+
644
+				log.Peer.Warnf("Underlying data for tx inv "+
644 645
 					"relay is not a *mempool.TxDesc: %T",
645 646
 					msg.Data)
646 647
 				return
@@ -820,7 +821,7 @@ func (s *Server) OutboundPeerConnected(cfg *cnf.Config, c *connmgr.ConnReq, conn
820 821
 	sp := NewServerPeer(s, c.Permanent)
821 822
 	p, err := peer.NewOutboundPeer(cfg, NewPeerConfig(cfg, sp), c.Addr.String())
822 823
 	if err != nil {
823
-		SrvrLog.Debugf("Cannot create outbound peer %s: %v", c.Addr, err)
824
+		log.Srvr.Debugf("Cannot create outbound peer %s: %v", c.Addr, err)
824 825
 		s.ConnManager.Disconnect(c.ID())
825 826
 	}
826 827
 	sp.Peer = p
@@ -844,8 +845,8 @@ func (s *Server) PeerDoneHandler(sp *ServerPeer) {
844 845
 		// Evict any remaining orphans that were sent by the peer.
845 846
 		numEvicted := s.TxMemPool.RemoveOrphansByTag(mempool.Tag(sp.ID()))
846 847
 		if numEvicted > 0 {
847
-			TxmpLog.Debugf("Evicted %d %s from peer %v (id %d)",
848
-				numEvicted, PickNoun(numEvicted, "orphan",
848
+			log.Txmp.Debugf("Evicted %d %s from peer %v (id %d)",
849
+				numEvicted, log.PickNoun(numEvicted, "orphan",
849 850
 					"orphans"), sp, sp.ID())
850 851
 		}
851 852
 	}
@@ -864,7 +865,7 @@ func (s *Server) PeerHandler(cfg *cnf.Config) {
864 865
 	s.AddrManager.Start(cfg)
865 866
 	s.SyncManager.Start()
866 867
 
867
-	SrvrLog.Tracef("Starting peer handler")
868
+	log.Srvr.Tracef("Starting peer handler")
868 869
 
869 870
 	state := &PeerState{
870 871
 		InboundPeers:    make(map[int32]*ServerPeer),
@@ -922,7 +923,7 @@ out:
922 923
 		case <-s.Quit:
923 924
 			// Disconnect all peers on server shutdown.
924 925
 			state.ForAllPeers(func(sp *ServerPeer) {
925
-				SrvrLog.Tracef("Shutdown peer %s", sp)
926
+				log.Srvr.Tracef("Shutdown peer %s", sp)
926 927
 				sp.Disconnect()
927 928
 			})
928 929
 			break out
@@ -949,7 +950,7 @@ cleanup:
949 950
 		}
950 951
 	}
951 952
 	s.Wg.Done()
952
-	SrvrLog.Tracef("Peer handler done")
953
+	log.Srvr.Tracef("Peer handler done")
953 954
 }
954 955
 
955 956
 // AddPeer adds a new peer that has already been connected to the server.
@@ -1090,7 +1091,7 @@ func (s *Server) Start(cfg *cnf.Config) {
1090 1091
 		return
1091 1092
 	}
1092 1093
 
1093
-	SrvrLog.Trace("Starting server")
1094
+	log.Srvr.Trace("Starting server")
1094 1095
 
1095 1096
 	// Server startup time. Used for the uptime command for uptime calculation.
1096 1097
 	s.StartupTime = time.Now().Unix()
@@ -1126,11 +1127,11 @@ func (s *Server) Start(cfg *cnf.Config) {
1126 1127
 func (s *Server) Stop(cfg *cnf.Config) error {
1127 1128
 	// Make sure this only happens once.
1128 1129
 	if atomic.AddInt32(&s.Shutdown, 1) != 1 {
1129
-		SrvrLog.Infof("Server is already in the process of shutting down")
1130
+		log.Srvr.Infof("Server is already in the process of shutting down")
1130 1131
 		return nil
1131 1132
 	}
1132 1133
 
1133
-	SrvrLog.Warnf("Server shutting down")
1134
+	log.Srvr.Warnf("Server shutting down")
1134 1135
 
1135 1136
 	// Stop the CPU miner if needed
1136 1137
 	s.CPUMiner.Stop()
@@ -1166,7 +1167,7 @@ func (s *Server) ScheduleShutdown(cfg *cnf.Config, duration time.Duration) {
1166 1167
 	if atomic.AddInt32(&s.ShutdownSched, 1) != 1 {
1167 1168
 		return
1168 1169
 	}
1169
-	SrvrLog.Warnf("Server shutdown in %v", duration)
1170
+	log.Srvr.Warnf("Server shutdown in %v", duration)
1170 1171
 	go func() {
1171 1172
 		remaining := duration
1172 1173
 		tickDuration := DynamicTickDuration(remaining)
@@ -1192,7 +1193,7 @@ func (s *Server) ScheduleShutdown(cfg *cnf.Config, duration time.Duration) {
1192 1193
 					ticker.Stop()
1193 1194
 					ticker = time.NewTicker(tickDuration)
1194 1195
 				}
1195
-				SrvrLog.Warnf("Server shutdown in %v", remaining)
1196
+				log.Srvr.Warnf("Server shutdown in %v", remaining)
1196 1197
 			}
1197 1198
 		}
1198 1199
 	}()
@@ -1330,14 +1331,14 @@ out:
1330 1331
 			listenPort, err := s.Nat.AddPortMapping("tcp", int(lport), int(lport),
1331 1332
 				"btcd listen port", 20*60)
1332 1333
 			if err != nil {
1333
-				SrvrLog.Warnf("can't add UPnP port mapping: %v", err)
1334
+				log.Srvr.Warnf("can't add UPnP port mapping: %v", err)
1334 1335
 			}
1335 1336
 			if first && err == nil {
1336 1337
 				// TODO: look this up periodically to see if upnp domain changed
1337 1338
 				// and so did ip.
1338 1339
 				externalip, err := s.Nat.GetExternalAddress()
1339 1340
 				if err != nil {
1340
-					SrvrLog.Warnf("UPnP can't get external address: %v", err)
1341
+					log.Srvr.Warnf("UPnP can't get external address: %v", err)
1341 1342
 					continue out
1342 1343
 				}
1343 1344
 				na := wire.NewNetAddressIPPort(externalip, uint16(listenPort),
@@ -1346,7 +1347,7 @@ out:
1346 1347
 				if err != nil {
1347 1348
 					// XXX DeletePortMapping?
1348 1349
 				}
1349
-				SrvrLog.Warnf("Successfully bound via UPnP to %s", addrmgr.NetAddressKey(na))
1350
+				log.Srvr.Warnf("Successfully bound via UPnP to %s", addrmgr.NetAddressKey(na))
1350 1351
 				first = false
1351 1352
 			}
1352 1353
 			timer.Reset(time.Minute * 15)
@@ -1358,9 +1359,9 @@ out:
1358 1359
 	timer.Stop()
1359 1360
 
1360 1361
 	if err := s.Nat.DeletePortMapping("tcp", int(lport), int(lport)); err != nil {
1361
-		SrvrLog.Warnf("unable to remove UPnP port mapping: %v", err)
1362
+		log.Srvr.Warnf("unable to remove UPnP port mapping: %v", err)
1362 1363
 	} else {
1363
-		SrvrLog.Debugf("successfully disestablished UPnP port mapping")
1364
+		log.Srvr.Debugf("successfully disestablished UPnP port mapping")
1364 1365
 	}
1365 1366
 
1366 1367
 	s.Wg.Done()
@@ -1406,7 +1407,7 @@ func SetupRPCListeners(cfg *cnf.Config) ([]net.Listener, error) {
1406 1407
 	for _, addr := range netAddrs {
1407 1408
 		listener, err := listenFunc(addr.Network(), addr.String())
1408 1409
 		if err != nil {
1409
-			RpcsLog.Warnf("Can't listen on %s: %v", addr, err)
1410
+			log.Rpcs.Warnf("Can't listen on %s: %v", addr, err)
1410 1411
 			continue
1411 1412
 		}
1412 1413
 		listeners = append(listeners, listener)
@@ -1446,10 +1447,10 @@ func NewServer(cfg *cnf.Config, listenAddrs, agentBlacklist, agentWhitelist []st
1446 1447
 	}
1447 1448
 
1448 1449
 	if len(agentBlacklist) > 0 {
1449
-		SrvrLog.Infof("User-agent blacklist %s", agentBlacklist)
1450
+		log.Srvr.Infof("User-agent blacklist %s", agentBlacklist)
1450 1451
 	}
1451 1452
 	if len(agentWhitelist) > 0 {
1452
-		SrvrLog.Infof("User-agent whitelist %s", agentWhitelist)
1453
+		log.Srvr.Infof("User-agent whitelist %s", agentWhitelist)
1453 1454
 	}
1454 1455
 
1455 1456
 	s := Server{
@@ -1486,23 +1487,23 @@ func NewServer(cfg *cnf.Config, listenAddrs, agentBlacklist, agentWhitelist []st
1486 1487
 		// Enable transaction index if address index is enabled since it
1487 1488
 		// requires it.
1488 1489
 		if !cfg.TxIndex {
1489
-			IndxLog.Infof("Transaction index enabled because it " +
1490
+			log.Indx.Infof("Transaction index enabled because it " +
1490 1491
 				"is required by the address index")
1491 1492
 			cfg.TxIndex = true
1492 1493
 		} else {
1493
-			IndxLog.Info("Transaction index is enabled")
1494
+			log.Indx.Info("Transaction index is enabled")
1494 1495
 		}
1495 1496
 
1496 1497
 		s.TxIndex = indexers.NewTxIndex(db)
1497 1498
 		indexes = append(indexes, s.TxIndex)
1498 1499
 	}
1499 1500
 	if cfg.AddrIndex {
1500
-		IndxLog.Info("Address index is enabled")
1501
+		log.Indx.Info("Address index is enabled")
1501 1502
 		s.AddrIndex = indexers.NewAddrIndex(db, chainParams)
1502 1503
 		indexes = append(indexes, s.AddrIndex)
1503 1504
 	}
1504 1505
 	if !cfg.NoCFilters {
1505
-		IndxLog.Info("Committed filter index is enabled")
1506
+		log.Indx.Info("Committed filter index is enabled")
1506 1507
 		s.CfIndex = indexers.NewCfIndex(db, chainParams)
1507 1508
 		indexes = append(indexes, s.CfIndex)
1508 1509
 	}
@@ -1550,7 +1551,7 @@ func NewServer(cfg *cnf.Config, listenAddrs, agentBlacklist, agentWhitelist []st
1550 1551
 			s.FeeEstimator, err = mempool.RestoreFeeEstimator(feeEstimationData)
1551 1552
 
1552 1553
 			if err != nil {
1553
-				PeerLog.Errorf("Failed to restore fee estimator %v", err)
1554
+				log.Peer.Errorf("Failed to restore fee estimator %v", err)
1554 1555
 			}
1555 1556
 		}
1556 1557
 
@@ -1768,7 +1769,7 @@ func InitListeners(cfg *cnf.Config, amgr *addrmgr.AddrManager, listenAddrs []str
1768 1769
 	for _, addr := range netAddrs {
1769 1770
 		listener, err := net.Listen(addr.Network(), addr.String())
1770 1771
 		if err != nil {
1771
-			SrvrLog.Warnf("Can't listen on %s: %v", addr, err)
1772
+			log.Srvr.Warnf("Can't listen on %s: %v", addr, err)
1772 1773
 			continue
1773 1774
 		}
1774 1775
 		listeners = append(listeners, listener)
@@ -1778,7 +1779,7 @@ func InitListeners(cfg *cnf.Config, amgr *addrmgr.AddrManager, listenAddrs []str
1778 1779
 	if len(cfg.ExternalIPs) != 0 {
1779 1780
 		defaultPort, err := strconv.ParseUint(cfg.StateActiveNet.DefaultPort, 10, 16)
1780 1781
 		if err != nil {
1781
-			SrvrLog.Errorf("Can not parse default port %s for active chain: %v",
1782
+			log.Srvr.Errorf("Can not parse default port %s for active chain: %v",
1782 1783
 				cfg.StateActiveNet.DefaultPort, err)
1783 1784
 			return nil, nil, err
1784 1785
 		}
@@ -1792,7 +1793,7 @@ func InitListeners(cfg *cnf.Config, amgr *addrmgr.AddrManager, listenAddrs []str
1792 1793
 			} else {
1793 1794
 				port, err := strconv.ParseUint(portstr, 10, 16)
1794 1795
 				if err != nil {
1795
-					SrvrLog.Warnf("Can not parse port from %s for "+
1796
+					log.Srvr.Warnf("Can not parse port from %s for "+
1796 1797
 						"externalip: %v", sip, err)
1797 1798
 					continue
1798 1799
 				}
@@ -1800,13 +1801,13 @@ func InitListeners(cfg *cnf.Config, amgr *addrmgr.AddrManager, listenAddrs []str
1800 1801
 			}
1801 1802
 			na, err := amgr.HostToNetAddress(cfg, host, eport, services)
1802 1803
 			if err != nil {
1803
-				SrvrLog.Warnf("Not adding %s as externalip: %v", sip, err)
1804
+				log.Srvr.Warnf("Not adding %s as externalip: %v", sip, err)
1804 1805
 				continue
1805 1806
 			}
1806 1807
 
1807 1808
 			err = amgr.AddLocalAddress(na, addrmgr.ManualPrio)
1808 1809
 			if err != nil {
1809
-				AmgrLog.Warnf("Skipping specified external IP: %v", err)
1810
+				log.Amgr.Warnf("Skipping specified external IP: %v", err)
1810 1811
 			}
1811 1812
 		}
1812 1813
 	} else {
@@ -1814,7 +1815,7 @@ func InitListeners(cfg *cnf.Config, amgr *addrmgr.AddrManager, listenAddrs []str
1814 1815
 			var err error
1815 1816
 			nat, err = upnp.Discover()
1816 1817
 			if err != nil {
1817
-				SrvrLog.Warnf("Can't discover upnp: %v", err)
1818
+				log.Srvr.Warnf("Can't discover upnp: %v", err)
1818 1819
 			}
1819 1820
 			// nil nat here is fine, just means no upnp on network.
1820 1821
 		}
@@ -1824,7 +1825,7 @@ func InitListeners(cfg *cnf.Config, amgr *addrmgr.AddrManager, listenAddrs []str
1824 1825
 			addr := listener.Addr().String()
1825 1826
 			err := AddLocalAddress(cfg, amgr, addr, services)
1826 1827
 			if err != nil {
1827
-				AmgrLog.Warnf("Skipping bound address %s: %v", addr, err)
1828
+				log.Amgr.Warnf("Skipping bound address %s: %v", addr, err)
1828 1829
 			}
1829 1830
 		}
1830 1831
 	}
@@ -1957,12 +1958,12 @@ func IsWhitelisted(cfg *cnf.Config, addr net.Addr) bool {
1957 1958
 
1958 1959
 	host, _, err := net.SplitHostPort(addr.String())
1959 1960
 	if err != nil {
1960
-		SrvrLog.Warnf("Unable to SplitHostPort on '%s': %v", addr, err)
1961
+		log.Srvr.Warnf("Unable to SplitHostPort on '%s': %v", addr, err)
1961 1962
 		return false
1962 1963
 	}
1963 1964
 	ip := net.ParseIP(host)
1964 1965
 	if ip == nil {
1965
-		SrvrLog.Warnf("Unable to parse IP '%s'", addr)
1966
+		log.Srvr.Warnf("Unable to parse IP '%s'", addr)
1966 1967
 		return false
1967 1968
 	}
1968 1969
 

btcd/serverpeer.go → node/serverpeer.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"fmt"
@@ -9,7 +9,8 @@ import (
9 9
 
10 10
 	"git.parallelcoin.io/dev/btcd/addrmgr"
11 11
 	"git.parallelcoin.io/dev/btcd/addrmgr/network"
12
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
12
+	"git.parallelcoin.io/dev/btcd/node/cnf"
13
+	"git.parallelcoin.io/dev/btcd/node/log"
13 14
 	"git.parallelcoin.io/dev/btcd/btcutil"
14 15
 	"git.parallelcoin.io/dev/btcd/btcutil/bloom"
15 16
 	"git.parallelcoin.io/dev/btcd/chaincfg"
@@ -108,7 +109,7 @@ func (sp *ServerPeer) ServerPushAddrMsg(addresses []*wire.NetAddress) {
108 109
 	}
109 110
 	known, err := sp.PushAddrMsg(addrs)
110 111
 	if err != nil {
111
-		PeerLog.Errorf("Can't push address message to %s: %v", sp.Peer, err)
112
+		log.Peer.Errorf("Can't push address message to %s: %v", sp.Peer, err)
112 113
 		sp.Disconnect()
113 114
 		return
114 115
 	}
@@ -126,7 +127,7 @@ func (sp *ServerPeer) AddBanScore(cfg *cnf.Config, persistent, transient uint32,
126 127
 		return
127 128
 	}
128 129
 	if sp.IsWhitelisted {
129
-		PeerLog.Debugf("Misbehaving whitelisted peer %s: %s", sp, reason)
130
+		log.Peer.Debugf("Misbehaving whitelisted peer %s: %s", sp, reason)
130 131
 		return
131 132
 	}
132 133
 
@@ -136,17 +137,17 @@ func (sp *ServerPeer) AddBanScore(cfg *cnf.Config, persistent, transient uint32,
136 137
 		// logged if the score is above the warn threshold.
137 138
 		score := sp.BanScore.Int()
138 139
 		if score > warnThreshold {
139
-			PeerLog.Warnf("Misbehaving peer %s: %s -- ban score is %d, "+
140
+			log.Peer.Warnf("Misbehaving peer %s: %s -- ban score is %d, "+
140 141
 				"it was not increased this time", sp, reason, score)
141 142
 		}
142 143
 		return
143 144
 	}
144 145
 	score := sp.BanScore.Increase(persistent, transient)
145 146
 	if score > warnThreshold {
146
-		PeerLog.Warnf("Misbehaving peer %s: %s -- ban score increased to %d",
147
+		log.Peer.Warnf("Misbehaving peer %s: %s -- ban score increased to %d",
147 148
 			sp, reason, score)
148 149
 		if score > cfg.BanThreshold {
149
-			PeerLog.Warnf("Misbehaving peer %s -- banning and disconnecting",
150
+			log.Peer.Warnf("Misbehaving peer %s -- banning and disconnecting",
150 151
 				sp)
151 152
 			sp.Server.BanPeer(sp)
152 153
 			sp.Disconnect()
@@ -185,7 +186,7 @@ func (sp *ServerPeer) OnVersion(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgVers
185 186
 	wantServices := wire.SFNodeNetwork
186 187
 	if !isInbound && !HasServices(msg.Services, wantServices) {
187 188
 		missingServices := wantServices & ^msg.Services
188
-		SrvrLog.Debugf("Rejecting peer %s with services %v due to not "+
189
+		log.Srvr.Debugf("Rejecting peer %s with services %v due to not "+
189 190
 			"providing desired services %v", sp.Peer, msg.Services,
190 191
 			missingServices)
191 192
 		reason := fmt.Sprintf("required services %#x not offered",
@@ -205,13 +206,13 @@ func (sp *ServerPeer) OnVersion(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgVers
205 206
 		chain := sp.Server.Chain
206 207
 		segwitActive, err := chain.IsDeploymentActive(chaincfg.DeploymentSegwit)
207 208
 		if err != nil {
208
-			PeerLog.Errorf("Unable to query for segwit soft-fork state: %v",
209
+			log.Peer.Errorf("Unable to query for segwit soft-fork state: %v",
209 210
 				err)
210 211
 			return nil
211 212
 		}
212 213
 
213 214
 		if segwitActive && !sp.IsWitnessEnabled() {
214
-			PeerLog.Infof("Disconnecting non-segwit peer %v, isn't segwit "+
215
+			log.Peer.Infof("Disconnecting non-segwit peer %v, isn't segwit "+
215 216
 				"enabled and we need more segwit enabled peers", sp)
216 217
 			sp.Disconnect()
217 218
 			return nil
@@ -265,7 +266,7 @@ func (sp *ServerPeer) OnMemPool(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgMemP
265 266
 	// Only allow mempool requests if the server has bloom filtering
266 267
 	// enabled.
267 268
 	if sp.Server.Services&wire.SFNodeBloom != wire.SFNodeBloom {
268
-		PeerLog.Debugf("peer %v sent mempool request with bloom "+
269
+		log.Peer.Debugf("peer %v sent mempool request with bloom "+
269 270
 			"filtering disabled -- disconnecting", sp)
270 271
 		sp.Disconnect()
271 272
 		return
@@ -311,7 +312,7 @@ func (sp *ServerPeer) OnMemPool(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgMemP
311 312
 // transactions don't rely on the previous one in a linear fashion like blocks.
312 313
 func (sp *ServerPeer) OnTx(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgTx) {
313 314
 	if cfg.BlocksOnly {
314
-		PeerLog.Tracef("Ignoring tx %v from %v - blocksonly enabled",
315
+		log.Peer.Tracef("Ignoring tx %v from %v - blocksonly enabled",
315 316
 			msg.TxHash(), sp)
316 317
 		return
317 318
 	}
@@ -373,10 +374,10 @@ func (sp *ServerPeer) OnInv(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgInv) {
373 374
 	newInv := wire.NewMsgInvSizeHint(uint(len(msg.InvList)))
374 375
 	for _, invVect := range msg.InvList {
375 376
 		if invVect.Type == wire.InvTypeTx {
376
-			PeerLog.Tracef("Ignoring tx %v in inv from %v -- "+
377
+			log.Peer.Tracef("Ignoring tx %v in inv from %v -- "+
377 378
 				"blocksonly enabled", invVect.Hash, sp)
378 379
 			if sp.ProtocolVersion() >= wire.BIP0037Version {
379
-				PeerLog.Infof("Peer %v is announcing "+
380
+				log.Peer.Infof("Peer %v is announcing "+
380 381
 					"transactions -- disconnecting", sp)
381 382
 				sp.Disconnect()
382 383
 				return
@@ -385,7 +386,7 @@ func (sp *ServerPeer) OnInv(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgInv) {
385 386
 		}
386 387
 		err := newInv.AddInvVect(invVect)
387 388
 		if err != nil {
388
-			PeerLog.Errorf("Failed to add inventory vector: %v", err)
389
+			log.Peer.Errorf("Failed to add inventory vector: %v", err)
389 390
 			break
390 391
 		}
391 392
 	}
@@ -448,7 +449,7 @@ func (sp *ServerPeer) OnGetData(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgGetD
448 449
 		case wire.InvTypeFilteredBlock:
449 450
 			err = sp.Server.PushMerkleBlockMsg(sp, &iv.Hash, c, waitChan, wire.BaseEncoding)
450 451
 		default:
451
-			PeerLog.Warnf("Unknown type in inventory request %d",
452
+			log.Peer.Warnf("Unknown type in inventory request %d",
452 453
 				iv.Type)
453 454
 			continue
454 455
 		}
@@ -563,7 +564,7 @@ func (sp *ServerPeer) OnGetCFilters(cfg *cnf.Config, _ *peer.Peer, msg *wire.Msg
563 564
 		break
564 565
 
565 566
 	default:
566
-		PeerLog.Debug("Filter request for unknown filter: %v",
567
+		log.Peer.Debug("Filter request for unknown filter: %v",
567 568
 			msg.FilterType)
568 569
 		return
569 570
 	}
@@ -572,7 +573,7 @@ func (sp *ServerPeer) OnGetCFilters(cfg *cnf.Config, _ *peer.Peer, msg *wire.Msg
572 573
 		int32(msg.StartHeight), &msg.StopHash, wire.MaxGetCFiltersReqRange,
573 574
 	)
574 575
 	if err != nil {
575
-		PeerLog.Debugf("Invalid getcfilters request: %v", err)
576
+		log.Peer.Debugf("Invalid getcfilters request: %v", err)
576 577
 		return
577 578
 	}
578 579
 
@@ -587,13 +588,13 @@ func (sp *ServerPeer) OnGetCFilters(cfg *cnf.Config, _ *peer.Peer, msg *wire.Msg
587 588
 		hashPtrs, msg.FilterType,
588 589
 	)
589 590
 	if err != nil {
590
-		PeerLog.Errorf("Error retrieving cfilters: %v", err)
591
+		log.Peer.Errorf("Error retrieving cfilters: %v", err)
591 592
 		return
592 593
 	}
593 594
 
594 595
 	for i, filterBytes := range filters {
595 596
 		if len(filterBytes) == 0 {
596
-			PeerLog.Warnf("Could not obtain cfilter for %v",
597
+			log.Peer.Warnf("Could not obtain cfilter for %v",
597 598
 				hashes[i])
598 599
 			return
599 600
 		}
@@ -619,7 +620,7 @@ func (sp *ServerPeer) OnGetCFHeaders(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
619 620
 		break
620 621
 
621 622
 	default:
622
-		PeerLog.Debug("Filter request for unknown headers for "+
623
+		log.Peer.Debug("Filter request for unknown headers for "+
623 624
 			"filter: %v", msg.FilterType)
624 625
 		return
625 626
 	}
@@ -639,14 +640,14 @@ func (sp *ServerPeer) OnGetCFHeaders(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
639 640
 		startHeight, &msg.StopHash, maxResults,
640 641
 	)
641 642
 	if err != nil {
642
-		PeerLog.Debugf("Invalid getcfheaders request: %v", err)
643
+		log.Peer.Debugf("Invalid getcfheaders request: %v", err)
643 644
 	}
644 645
 
645 646
 	// This is possible if StartHeight is one greater that the height of
646 647
 	// StopHash, and we pull a valid range of hashes including the previous
647 648
 	// filter header.
648 649
 	if len(hashList) == 0 || (msg.StartHeight > 0 && len(hashList) == 1) {
649
-		PeerLog.Debug("No results for getcfheaders request")
650
+		log.Peer.Debug("No results for getcfheaders request")
650 651
 		return
651 652
 	}
652 653
 
@@ -662,7 +663,7 @@ func (sp *ServerPeer) OnGetCFHeaders(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
662 663
 		hashPtrs, msg.FilterType,
663 664
 	)
664 665
 	if err != nil {
665
-		PeerLog.Errorf("Error retrieving cfilter hashes: %v", err)
666
+		log.Peer.Errorf("Error retrieving cfilter hashes: %v", err)
666 667
 		return
667 668
 	}
668 669
 
@@ -678,18 +679,18 @@ func (sp *ServerPeer) OnGetCFHeaders(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
678 679
 		headerBytes, err := sp.Server.CfIndex.FilterHeaderByBlockHash(
679 680
 			prevBlockHash, msg.FilterType)
680 681
 		if err != nil {
681
-			PeerLog.Errorf("Error retrieving CF header: %v", err)
682
+			log.Peer.Errorf("Error retrieving CF header: %v", err)
682 683
 			return
683 684
 		}
684 685
 		if len(headerBytes) == 0 {
685
-			PeerLog.Warnf("Could not obtain CF header for %v", prevBlockHash)
686
+			log.Peer.Warnf("Could not obtain CF header for %v", prevBlockHash)
686 687
 			return
687 688
 		}
688 689
 
689 690
 		// Deserialize the hash into PrevFilterHeader.
690 691
 		err = headersMsg.PrevFilterHeader.SetBytes(headerBytes)
691 692
 		if err != nil {
692
-			PeerLog.Warnf("Committed filter header deserialize "+
693
+			log.Peer.Warnf("Committed filter header deserialize "+
693 694
 				"failed: %v", err)
694 695
 			return
695 696
 		}
@@ -701,14 +702,14 @@ func (sp *ServerPeer) OnGetCFHeaders(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
701 702
 	// Populate HeaderHashes.
702 703
 	for i, hashBytes := range filterHashes {
703 704
 		if len(hashBytes) == 0 {
704
-			PeerLog.Warnf("Could not obtain CF hash for %v", hashList[i])
705
+			log.Peer.Warnf("Could not obtain CF hash for %v", hashList[i])
705 706
 			return
706 707
 		}
707 708
 
708 709
 		// Deserialize the hash.
709 710
 		filterHash, err := chainhash.NewHash(hashBytes)
710 711
 		if err != nil {
711
-			PeerLog.Warnf("Committed filter hash deserialize "+
712
+			log.Peer.Warnf("Committed filter hash deserialize "+
712 713
 				"failed: %v", err)
713 714
 			return
714 715
 		}
@@ -736,7 +737,7 @@ func (sp *ServerPeer) OnGetCFCheckpt(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
736 737
 		break
737 738
 
738 739
 	default:
739
-		PeerLog.Debug("Filter request for unknown checkpoints for "+
740
+		log.Peer.Debug("Filter request for unknown checkpoints for "+
740 741
 			"filter: %v", msg.FilterType)
741 742
 		return
742 743
 	}
@@ -748,7 +749,7 @@ func (sp *ServerPeer) OnGetCFCheckpt(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
748 749
 		&msg.StopHash, wire.CFCheckptInterval,
749 750
 	)
750 751
 	if err != nil {
751
-		PeerLog.Debugf("Invalid getcfilters request: %v", err)
752
+		log.Peer.Debugf("Invalid getcfilters request: %v", err)
752 753
 		return
753 754
 	}
754 755
 
@@ -787,7 +788,7 @@ func (sp *ServerPeer) OnGetCFCheckpt(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
787 788
 			additionalLength := len(blockHashes) - len(checkptCache)
788 789
 			newEntries := make([]CfHeaderKV, additionalLength)
789 790
 
790
-			PeerLog.Infof("Growing size of checkpoint cache from %v to %v "+
791
+			log.Peer.Infof("Growing size of checkpoint cache from %v to %v "+
791 792
 				"block hashes", len(checkptCache), len(blockHashes))
792 793
 
793 794
 			checkptCache = append(
@@ -800,7 +801,7 @@ func (sp *ServerPeer) OnGetCFCheckpt(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
800 801
 		// of this method.
801 802
 		defer sp.Server.CfCheckptCachesMtx.RUnlock()
802 803
 
803
-		PeerLog.Tracef("Serving stale cache of size %v",
804
+		log.Peer.Tracef("Serving stale cache of size %v",
804 805
 			len(checkptCache))
805 806
 	}
806 807
 
@@ -832,7 +833,7 @@ func (sp *ServerPeer) OnGetCFCheckpt(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
832 833
 		blockHashPtrs, msg.FilterType,
833 834
 	)
834 835
 	if err != nil {
835
-		PeerLog.Errorf("Error retrieving cfilter headers: %v", err)
836
+		log.Peer.Errorf("Error retrieving cfilter headers: %v", err)
836 837
 		return
837 838
 	}
838 839
 
@@ -840,14 +841,14 @@ func (sp *ServerPeer) OnGetCFCheckpt(cfg *cnf.Config, _ *peer.Peer, msg *wire.Ms
840 841
 	// the checkpoint message, and also update our cache in line.
841 842
 	for i, filterHeaderBytes := range filterHeaders {
842 843
 		if len(filterHeaderBytes) == 0 {
843
-			PeerLog.Warnf("Could not obtain CF header for %v",
844
+			log.Peer.Warnf("Could not obtain CF header for %v",
844 845
 				blockHashPtrs[i])
845 846
 			return
846 847
 		}
847 848
 
848 849
 		filterHeader, err := chainhash.NewHash(filterHeaderBytes)
849 850
 		if err != nil {
850
-			PeerLog.Warnf("Committed filter header deserialize "+
851
+			log.Peer.Warnf("Committed filter header deserialize "+
851 852
 				"failed: %v", err)
852 853
 			return
853 854
 		}
@@ -899,7 +900,7 @@ func (sp *ServerPeer) EnforceNodeBloomFlag(cfg *cnf.Config, cmd string) bool {
899 900
 
900 901
 		// Disconnect the peer regardless of protocol version or banning
901 902
 		// state.
902
-		PeerLog.Debugf("%s sent an unsupported %s request -- "+
903
+		log.Peer.Debugf("%s sent an unsupported %s request -- "+
903 904
 			"disconnecting", sp, cmd)
904 905
 		sp.Disconnect()
905 906
 		return false
@@ -915,7 +916,7 @@ func (sp *ServerPeer) EnforceNodeBloomFlag(cfg *cnf.Config, cmd string) bool {
915 916
 func (sp *ServerPeer) OnFeeFilter(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgFeeFilter) {
916 917
 	// Check that the passed minimum fee is a valid amount.
917 918
 	if msg.MinFee < 0 || msg.MinFee > btcutil.MaxSatoshi {
918
-		PeerLog.Debugf("Peer %v sent an invalid feefilter '%v' -- "+
919
+		log.Peer.Debugf("Peer %v sent an invalid feefilter '%v' -- "+
919 920
 			"disconnecting", sp, btcutil.Amount(msg.MinFee))
920 921
 		sp.Disconnect()
921 922
 		return
@@ -936,7 +937,7 @@ func (sp *ServerPeer) OnFilterAdd(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgFi
936 937
 	}
937 938
 
938 939
 	if !sp.Filter.IsLoaded() {
939
-		PeerLog.Debugf("%s sent a filteradd request with no filter "+
940
+		log.Peer.Debugf("%s sent a filteradd request with no filter "+
940 941
 			"loaded -- disconnecting", sp)
941 942
 		sp.Disconnect()
942 943
 		return
@@ -957,7 +958,7 @@ func (sp *ServerPeer) OnFilterClear(cfg *cnf.Config, _ *peer.Peer, msg *wire.Msg
957 958
 	}
958 959
 
959 960
 	if !sp.Filter.IsLoaded() {
960
-		PeerLog.Debugf("%s sent a filterclear request with no "+
961
+		log.Peer.Debugf("%s sent a filterclear request with no "+
961 962
 			"filter loaded -- disconnecting", sp)
962 963
 		sp.Disconnect()
963 964
 		return
@@ -998,7 +999,7 @@ func (sp *ServerPeer) OnGetAddr(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgGetA
998 999
 	// Do not accept getaddr requests from outbound peers.  This reduces
999 1000
 	// fingerprinting attacks.
1000 1001
 	if !sp.Inbound() {
1001
-		PeerLog.Debugf("Ignoring getaddr request from outbound peer ",
1002
+		log.Peer.Debugf("Ignoring getaddr request from outbound peer ",
1002 1003
 			"%v", sp)
1003 1004
 		return
1004 1005
 	}
@@ -1006,7 +1007,7 @@ func (sp *ServerPeer) OnGetAddr(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgGetA
1006 1007
 	// Only allow one getaddr request per connection to discourage
1007 1008
 	// address stamping of inv announcements.
1008 1009
 	if sp.SentAddrs {
1009
-		PeerLog.Debugf("Ignoring repeated getaddr request from peer ",
1010
+		log.Peer.Debugf("Ignoring repeated getaddr request from peer ",
1010 1011
 			"%v", sp)
1011 1012
 		return
1012 1013
 	}
@@ -1037,7 +1038,7 @@ func (sp *ServerPeer) OnAddr(cfg *cnf.Config, _ *peer.Peer, msg *wire.MsgAddr) {
1037 1038
 
1038 1039
 	// A message that has no addresses is invalid.
1039 1040
 	if len(msg.AddrList) == 0 {
1040
-		PeerLog.Errorf("Command [%s] from %s does not contain any addresses",
1041
+		log.Peer.Errorf("Command [%s] from %s does not contain any addresses",
1041 1042
 			msg.Command(), sp.Peer)
1042 1043
 		sp.Disconnect()
1043 1044
 		return
@@ -1097,7 +1098,7 @@ func (sp *ServerPeer) HasUndesiredUserAgent(blacklistedAgents,
1097 1098
 	// will ignore the connection request.
1098 1099
 	for _, blacklistedAgent := range blacklistedAgents {
1099 1100
 		if strings.Contains(agent, blacklistedAgent) {
1100
-			SrvrLog.Debugf("Ignoring peer %s, user agent "+
1101
+			log.Srvr.Debugf("Ignoring peer %s, user agent "+
1101 1102
 				"contains blacklisted user agent: %s", sp,
1102 1103
 				agent)
1103 1104
 			return true
@@ -1119,7 +1120,7 @@ func (sp *ServerPeer) HasUndesiredUserAgent(blacklistedAgents,
1119 1120
 
1120 1121
 	// Otherwise, the peer's user agent was not included in our whitelist.
1121 1122
 	// Ignore just in case it could stall the initial block download.
1122
-	SrvrLog.Debugf("Ignoring peer %s, user agent: %s not found in "+
1123
+	log.Srvr.Debugf("Ignoring peer %s, user agent: %s not found in "+
1123 1124
 		"whitelist", sp, agent)
1124 1125
 
1125 1126
 	return true

btcd/service_windows.go → node/service_windows.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"fmt"
@@ -28,10 +28,6 @@ const (
28 28
 // Elog is used to send messages to the Windows event log.
29 29
 var Elog *eventlog.Log
30 30
 
31
-// WinServiceMain is only invoked on Windows.  It detects when btcd is running
32
-// as a service and reacts accordingly.
33
-var WinServiceMain func() (bool, error)
34
-
35 31
 // LogServiceStartOfDay logs information about btcd when the main server has
36 32
 // been started to the Windows event log.
37 33
 func LogServiceStartOfDay(srvr *server) {
@@ -44,15 +40,15 @@ func LogServiceStartOfDay(srvr *server) {
44 40
 	Elog.Info(1, message)
45 41
 }
46 42
 
47
-// BtcdService houses the main service handler which handles all service
43
+// Service houses the main service handler which handles all service
48 44
 // updates and launching btcdMain.
49
-type BtcdService struct{}
45
+type Service struct{}
50 46
 
51 47
 // Execute is the main entry point the winsvc package calls when receiving
52 48
 // information from the Windows service control manager.  It launches the
53 49
 // long-running btcdMain (which is the real meat of btcd), handles service
54 50
 // change requests, and notifies the service control manager of changes.
55
-func (s *BtcdService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
51
+func (s *Service) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
56 52
 	// Service start is pending.
57 53
 	const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown
58 54
 	changes <- svc.Status{State: svc.StartPending}
@@ -291,7 +287,7 @@ func ServiceMain() (bool, error) {
291 287
 	}
292 288
 	defer Elog.Close()
293 289
 
294
-	err = svc.Run(SvcName, &BtcdService{})
290
+	err = svc.Run(SvcName, &Service{})
295 291
 	if err != nil {
296 292
 		Elog.Error(1, fmt.Sprintf("Service start failed: %v", err))
297 293
 		return true, err
@@ -302,6 +298,6 @@ func ServiceMain() (bool, error) {
302 298
 
303 299
 // Set windows specific functions to real functions.
304 300
 func init() {
305
-	runServiceCommand = PerformServiceCommand
306
-	winServiceMain = ServiceMain
301
+	RunServiceCommand = PerformServiceCommand
302
+	WinServiceMain = ServiceMain
307 303
 }

btcd/signal.go → node/signal.go View File

@@ -1,8 +1,10 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"os"
5 5
 	"os/signal"
6
+
7
+	"git.parallelcoin.io/dev/btcd/node/log"
6 8
 )
7 9
 
8 10
 // ShutdownRequestChannel is used to initiate shutdown from one of the
@@ -26,11 +28,11 @@ func InterruptListener() <-chan struct{} {
26 28
 		// channel to notify the caller.
27 29
 		select {
28 30
 		case sig := <-interruptChannel:
29
-			BtcdLog.Infof("Received signal (%s).  Shutting down...",
31
+			log.Btcd.Infof("Received signal (%s).  Shutting down...",
30 32
 				sig)
31 33
 
32 34
 		case <-ShutdownRequestChannel:
33
-			BtcdLog.Info("Shutdown requested.  Shutting down...")
35
+			log.Btcd.Info("Shutdown requested.  Shutting down...")
34 36
 		}
35 37
 		close(c)
36 38
 
@@ -40,11 +42,11 @@ func InterruptListener() <-chan struct{} {
40 42
 		for {
41 43
 			select {
42 44
 			case sig := <-interruptChannel:
43
-				BtcdLog.Infof("Received signal (%s).  Already "+
45
+				log.Btcd.Infof("Received signal (%s).  Already "+
44 46
 					"shutting down...", sig)
45 47
 
46 48
 			case <-ShutdownRequestChannel:
47
-				BtcdLog.Info("Shutdown requested.  Already " +
49
+				log.Btcd.Info("Shutdown requested.  Already " +
48 50
 					"shutting down...")
49 51
 			}
50 52
 		}

btcd/signalsigterm.go → node/signalsigterm.go View File

@@ -1,6 +1,6 @@
1 1
 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
2 2
 
3
-package btcd
3
+package node
4 4
 
5 5
 import (
6 6
 	"os"

btcd/simple/addr.go → node/simple/addr.go View File


btcd/upgrade.go → node/upgrade/upgrade.go View File

@@ -1,37 +1,19 @@
1
-package btcd
1
+package upgrade
2 2
 
3 3
 import (
4
-	"io"
5 4
 	"os"
6 5
 	"path/filepath"
7 6
 
8
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
9
-	"git.parallelcoin.io/dev/btcd/btcd/defaults"
7
+	"git.parallelcoin.io/dev/btcd/node/cnf"
8
+	"git.parallelcoin.io/dev/btcd/node/defaults"
9
+	"git.parallelcoin.io/dev/btcd/node/log"
10 10
 	"git.parallelcoin.io/dev/btcd/util"
11 11
 )
12 12
 
13
-// dirEmpty returns whether or not the specified directory path is empty.
14
-func dirEmpty(dirPath string) (bool, error) {
15
-	f, err := os.Open(dirPath)
16
-	if err != nil {
17
-		return false, err
18
-	}
19
-	defer f.Close()
20
-
21
-	// Read the names of a max of one entry from the directory.  When the
22
-	// directory is empty, an io.EOF error will be returned, so allow it.
23
-	names, err := f.Readdirnames(1)
24
-	if err != nil && err != io.EOF {
25
-		return false, err
26
-	}
27
-
28
-	return len(names) == 0, nil
29
-}
30
-
31
-// oldBtcdHomeDir returns the OS specific home directory btcd used prior to
13
+// OldBtcdHomeDir returns the OS specific home directory btcd used prior to
32 14
 // version 0.3.3.  This has since been replaced with btcutil.AppDataDir, but
33 15
 // this function is still provided for the automatic upgrade path.
34
-func oldBtcdHomeDir() string {
16
+func OldBtcdHomeDir() string {
35 17
 	// Search for Windows APPDATA first.  This won't exist on POSIX OSes.
36 18
 	appData := os.Getenv("APPDATA")
37 19
 	if appData != "" {
@@ -48,10 +30,10 @@ func oldBtcdHomeDir() string {
48 30
 	return "."
49 31
 }
50 32
 
51
-// upgradeDBPathNet moves the database for a specific network from its
33
+// DBPathNet moves the database for a specific network from its
52 34
 // location prior to btcd version 0.2.0 and uses heuristics to ascertain the old
53 35
 // database type to rename to the new format.
54
-func upgradeDBPathNet(cfg *cnf.Config, oldDbPath, netName string) error {
36
+func DBPathNet(cfg *cnf.Config, oldDbPath, netName string) error {
55 37
 	// Prior to version 0.2.0, the database was named the same thing for
56 38
 	// both sqlite and leveldb.  Use heuristics to figure out the type
57 39
 	// of the database and move it to the new path and name introduced with
@@ -66,7 +48,7 @@ func upgradeDBPathNet(cfg *cnf.Config, oldDbPath, netName string) error {
66 48
 		// The new database name is based on the database type and
67 49
 		// resides in a directory named after the network type.
68 50
 		newDbRoot := filepath.Join(filepath.Dir(cfg.DataDir), netName)
69
-		newDbName := BlockDbNamePrefix + "_" + oldDbType
51
+		newDbName := cnf.BlockDbNamePrefix + "_" + oldDbType
70 52
 		if oldDbType == "sqlite" {
71 53
 			newDbName = newDbName + ".db"
72 54
 		}
@@ -88,27 +70,27 @@ func upgradeDBPathNet(cfg *cnf.Config, oldDbPath, netName string) error {
88 70
 	return nil
89 71
 }
90 72
 
91
-// upgradeDBPaths moves the databases from their locations prior to btcd
73
+// DBPaths moves the databases from their locations prior to btcd
92 74
 // version 0.2.0 to their new locations.
93
-func upgradeDBPaths(cfg *cnf.Config) error {
75
+func DBPaths(cfg *cnf.Config) error {
94 76
 	// Prior to version 0.2.0, the databases were in the "db" directory and
95 77
 	// their names were suffixed by "testnet" and "regtest" for their
96 78
 	// respective networks.  Check for the old database and update it to the
97 79
 	// new path introduced with version 0.2.0 accordingly.
98
-	oldDbRoot := filepath.Join(oldBtcdHomeDir(), "db")
99
-	upgradeDBPathNet(cfg, filepath.Join(oldDbRoot, "btcd.db"), "mainnet")
100
-	upgradeDBPathNet(cfg, filepath.Join(oldDbRoot, "btcd_testnet.db"), "testnet")
101
-	upgradeDBPathNet(cfg, filepath.Join(oldDbRoot, "btcd_regtest.db"), "regtest")
80
+	oldDbRoot := filepath.Join(OldBtcdHomeDir(), "db")
81
+	DBPathNet(cfg, filepath.Join(oldDbRoot, "btcd.db"), "mainnet")
82
+	DBPathNet(cfg, filepath.Join(oldDbRoot, "btcd_testnet.db"), "testnet")
83
+	DBPathNet(cfg, filepath.Join(oldDbRoot, "btcd_regtest.db"), "regtest")
102 84
 
103 85
 	// Remove the old db directory.
104 86
 	return os.RemoveAll(oldDbRoot)
105 87
 }
106 88
 
107
-// upgradeDataPaths moves the application data from its location prior to btcd
89
+// DataPaths moves the application data from its location prior to btcd
108 90
 // version 0.3.3 to its new location.
109
-func upgradeDataPaths() error {
91
+func DataPaths() error {
110 92
 	// No need to migrate if the old and new home paths are the same.
111
-	oldHomePath := oldBtcdHomeDir()
93
+	oldHomePath := OldBtcdHomeDir()
112 94
 	newHomePath := defaults.HomeDir
113 95
 	if oldHomePath == newHomePath {
114 96
 		return nil
@@ -117,7 +99,7 @@ func upgradeDataPaths() error {
117 99
 	// Only migrate if the old path exists and the new one doesn't.
118 100
 	if util.FileExists(oldHomePath) && !util.FileExists(newHomePath) {
119 101
 		// Create the new path.
120
-		BtcdLog.Infof("Migrating application home path from '%s' to '%s'",
102
+		log.Btcd.Infof("Migrating application home path from '%s' to '%s'",
121 103
 			oldHomePath, newHomePath)
122 104
 		err := os.MkdirAll(newHomePath, 0700)
123 105
 		if err != nil {
@@ -145,7 +127,7 @@ func upgradeDataPaths() error {
145 127
 		}
146 128
 
147 129
 		// Remove the old home if it is empty or show a warning if not.
148
-		ohpEmpty, err := dirEmpty(oldHomePath)
130
+		ohpEmpty, err := util.DirEmpty(oldHomePath)
149 131
 		if err != nil {
150 132
 			return err
151 133
 		}
@@ -155,7 +137,7 @@ func upgradeDataPaths() error {
155 137
 				return err
156 138
 			}
157 139
 		} else {
158
-			BtcdLog.Warnf("Not removing '%s' since it contains files "+
140
+			log.Btcd.Warnf("Not removing '%s' since it contains files "+
159 141
 				"not created by this application.  You may "+
160 142
 				"want to manually move them or delete them.",
161 143
 				oldHomePath)
@@ -165,11 +147,11 @@ func upgradeDataPaths() error {
165 147
 	return nil
166 148
 }
167 149
 
168
-// doUpgrades performs upgrades to btcd as new versions require it.
169
-func doUpgrades(cfg *cnf.Config) error {
170
-	err := upgradeDBPaths(cfg)
150
+// Do performs upgrades to btcd as new versions require it.
151
+func Do(cfg *cnf.Config) error {
152
+	err := DBPaths(cfg)
171 153
 	if err != nil {
172 154
 		return err
173 155
 	}
174
-	return upgradeDataPaths()
156
+	return DataPaths()
175 157
 }

btcd/upnp/upnp.go → node/upnp/upnp.go View File


btcd/util.go → node/util.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"fmt"
@@ -7,8 +7,8 @@ import (
7 7
 	"path/filepath"
8 8
 	"strings"
9 9
 
10
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
11
-	"git.parallelcoin.io/dev/btcd/btcd/defaults"
10
+	"git.parallelcoin.io/dev/btcd/node/cnf"
11
+	"git.parallelcoin.io/dev/btcd/node/defaults"
12 12
 )
13 13
 
14 14
 // MinUint32 is a helper function to return the minimum of two uint32s.

btcd/version/version.go → node/version/version.go View File


btcd/wsclient.go → node/wsclient.go View File

@@ -1,4 +1,4 @@
1
-package btcd
1
+package node
2 2
 
3 3
 import (
4 4
 	"container/list"
@@ -9,7 +9,8 @@ import (
9 9
 	"io"
10 10
 	"sync"
11 11
 
12
-	"git.parallelcoin.io/dev/btcd/btcd/cnf"
12
+	"git.parallelcoin.io/dev/btcd/node/cnf"
13
+	"git.parallelcoin.io/dev/btcd/node/log"
13 14
 	"git.parallelcoin.io/dev/btcd/btcjson"
14 15
 	sem "git.parallelcoin.io/dev/btcd/util/semaphore"
15 16
 	"git.parallelcoin.io/dev/btcd/wire"
@@ -135,7 +136,7 @@ out:
135 136
 		if err != nil {
136 137
 			// Log the error if it's not due to disconnecting.
137 138
 			if err != io.EOF {
138
-				RpcsLog.Errorf("Websocket receive error from "+
139
+				log.Rpcs.Errorf("Websocket receive error from "+
139 140
 					"%s: %v", c.Addr, err)
140 141
 			}
141 142
 			break out
@@ -154,7 +155,7 @@ out:
154 155
 			}
155 156
 			reply, err := CreateMarshalledReply(nil, nil, jsonErr)
156 157
 			if err != nil {
157
-				RpcsLog.Errorf("Failed to marshal parse failure "+
158
+				log.Rpcs.Errorf("Failed to marshal parse failure "+
158 159
 					"reply: %v", err)
159 160
 				continue
160 161
 			}
@@ -195,14 +196,14 @@ out:
195 196
 
196 197
 			reply, err := CreateMarshalledReply(cmd.ID, nil, cmd.Err)
197 198
 			if err != nil {
198
-				RpcsLog.Errorf("Failed to marshal parse failure "+
199
+				log.Rpcs.Errorf("Failed to marshal parse failure "+
199 200
 					"reply: %v", err)
200 201
 				continue
201 202
 			}
202 203
 			c.SendMessage(reply, nil)
203 204
 			continue
204 205
 		}
205