|
@ -125,7 +125,7 @@ type pssSub struct { |
|
|
Address string |
|
|
Address string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type SwarmNet struct { |
|
|
|
|
|
|
|
|
type SimplePss struct { |
|
|
Node *node.Node |
|
|
Node *node.Node |
|
|
NodeConfig *node.Config |
|
|
NodeConfig *node.Config |
|
|
EnodeID string |
|
|
EnodeID string |
|
@ -139,7 +139,7 @@ type SwarmNet struct { |
|
|
Ports *swarmPorts |
|
|
Ports *swarmPorts |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) SetLog(level string) error { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) SetLog(level string) error { |
|
|
// ensure good log formats for terminal
|
|
|
// ensure good log formats for terminal
|
|
|
// handle verbosity flag
|
|
|
// handle verbosity flag
|
|
|
loglevel, err := log.LvlFromString(level) |
|
|
loglevel, err := log.LvlFromString(level) |
|
@ -153,7 +153,7 @@ func (sn *SwarmNet) SetLog(level string) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) PrintStats() { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) PrintStats() { |
|
|
// statistics thread
|
|
|
// statistics thread
|
|
|
go func() { |
|
|
go func() { |
|
|
for { |
|
|
for { |
|
@ -169,15 +169,15 @@ func (sn *SwarmNet) PrintStats() { |
|
|
}() |
|
|
}() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) SetDatadir(datadir string) { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) SetDatadir(datadir string) { |
|
|
sn.Datadir = datadir |
|
|
sn.Datadir = datadir |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) SetKey(key *ecdsa.PrivateKey) { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) SetKey(key *ecdsa.PrivateKey) { |
|
|
sn.Key = key |
|
|
sn.Key = key |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) Init() error { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) Init() error { |
|
|
var err error |
|
|
var err error |
|
|
if len(sn.Datadir) < 1 { |
|
|
if len(sn.Datadir) < 1 { |
|
|
usr, err := user.Current() |
|
|
usr, err := user.Current() |
|
@ -269,7 +269,7 @@ func strAddress(addr string) pss.PssAddress { |
|
|
return pssAddress |
|
|
return pssAddress |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) PssSub(subType, key, topic, address string) error { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) PssSub(subType, key, topic, address string) error { |
|
|
pssTopic := strTopic(topic) |
|
|
pssTopic := strTopic(topic) |
|
|
pssAddress := strAddress(address) |
|
|
pssAddress := strAddress(address) |
|
|
if subType == "sym" { |
|
|
if subType == "sym" { |
|
@ -299,7 +299,7 @@ func (sn *SwarmNet) PssSub(subType, key, topic, address string) error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sn *SwarmNet) PssPub(subType, key, topic, msg, address string) error { |
|
|
|
|
|
|
|
|
func (sn *SimplePss) PssPub(subType, key, topic, msg, address string) error { |
|
|
var err error |
|
|
var err error |
|
|
dstAddr := strAddress(address) |
|
|
dstAddr := strAddress(address) |
|
|
dstTopic := strTopic(topic) |
|
|
dstTopic := strTopic(topic) |
|
|