mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
swarm, pot, p2p, internal: typos and gofmt -s
This commit is contained in:
parent
dcd03063db
commit
9e61e26ad5
16 changed files with 65 additions and 65 deletions
|
|
@ -2307,7 +2307,7 @@ var toChecksumAddress = function (address) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms given string to valid 20 bytes-length addres with 0x prefix
|
* Transforms given string to valid 20 bytes-length address with 0x prefix
|
||||||
*
|
*
|
||||||
* @method toAddress
|
* @method toAddress
|
||||||
* @param {String} address
|
* @param {String} address
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ type Peer struct {
|
||||||
|
|
||||||
// NewPeer constructs a new peer
|
// NewPeer constructs a new peer
|
||||||
// this constructor is called by the p2p.Protocol#Run function
|
// this constructor is called by the p2p.Protocol#Run function
|
||||||
// the first two arguments are comming the arguments passed to p2p.Protocol.Run function
|
// the first two arguments are coming the arguments passed to p2p.Protocol.Run function
|
||||||
// the third argument is the CodeMap describing the protocol messages and options
|
// the third argument is the CodeMap describing the protocol messages and options
|
||||||
func NewPeer(p *p2p.Peer, rw p2p.MsgReadWriter, spec *Spec) *Peer {
|
func NewPeer(p *p2p.Peer, rw p2p.MsgReadWriter, spec *Spec) *Peer {
|
||||||
return &Peer{
|
return &Peer{
|
||||||
|
|
|
||||||
|
|
@ -154,18 +154,18 @@ func protocolTester(t *testing.T, pp *p2ptest.TestPeerPool) *p2ptest.ProtocolTes
|
||||||
func protoHandshakeExchange(id discover.NodeID, proto *protoHandshake) []p2ptest.Exchange {
|
func protoHandshakeExchange(id discover.NodeID, proto *protoHandshake) []p2ptest.Exchange {
|
||||||
|
|
||||||
return []p2ptest.Exchange{
|
return []p2ptest.Exchange{
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &protoHandshake{42, "420"},
|
Msg: &protoHandshake{42, "420"},
|
||||||
Peer: id,
|
Peer: id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: proto,
|
Msg: proto,
|
||||||
Peer: id,
|
Peer: id,
|
||||||
|
|
@ -207,18 +207,18 @@ func TestProtoHandshakeSuccess(t *testing.T) {
|
||||||
func moduleHandshakeExchange(id discover.NodeID, resp uint) []p2ptest.Exchange {
|
func moduleHandshakeExchange(id discover.NodeID, resp uint) []p2ptest.Exchange {
|
||||||
|
|
||||||
return []p2ptest.Exchange{
|
return []p2ptest.Exchange{
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &hs0{42},
|
Msg: &hs0{42},
|
||||||
Peer: id,
|
Peer: id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &hs0{resp},
|
Msg: &hs0{resp},
|
||||||
Peer: id,
|
Peer: id,
|
||||||
|
|
@ -255,42 +255,42 @@ func TestModuleHandshakeSuccess(t *testing.T) {
|
||||||
func testMultiPeerSetup(a, b discover.NodeID) []p2ptest.Exchange {
|
func testMultiPeerSetup(a, b discover.NodeID) []p2ptest.Exchange {
|
||||||
|
|
||||||
return []p2ptest.Exchange{
|
return []p2ptest.Exchange{
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Label: "primary handshake",
|
Label: "primary handshake",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &protoHandshake{42, "420"},
|
Msg: &protoHandshake{42, "420"},
|
||||||
Peer: a,
|
Peer: a,
|
||||||
},
|
},
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &protoHandshake{42, "420"},
|
Msg: &protoHandshake{42, "420"},
|
||||||
Peer: b,
|
Peer: b,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Label: "module handshake",
|
Label: "module handshake",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &protoHandshake{42, "420"},
|
Msg: &protoHandshake{42, "420"},
|
||||||
Peer: a,
|
Peer: a,
|
||||||
},
|
},
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &protoHandshake{42, "420"},
|
Msg: &protoHandshake{42, "420"},
|
||||||
Peer: b,
|
Peer: b,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &hs0{42},
|
Msg: &hs0{42},
|
||||||
Peer: a,
|
Peer: a,
|
||||||
},
|
},
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &hs0{42},
|
Msg: &hs0{42},
|
||||||
Peer: b,
|
Peer: b,
|
||||||
|
|
@ -298,10 +298,10 @@ func testMultiPeerSetup(a, b discover.NodeID) []p2ptest.Exchange {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
p2ptest.Exchange{Label: "alternative module handshake", Triggers: []p2ptest.Trigger{p2ptest.Trigger{Code: 1, Msg: &hs0{41}, Peer: a},
|
{Label: "alternative module handshake", Triggers: []p2ptest.Trigger{{Code: 1, Msg: &hs0{41}, Peer: a},
|
||||||
p2ptest.Trigger{Code: 1, Msg: &hs0{41}, Peer: b}}},
|
{Code: 1, Msg: &hs0{41}, Peer: b}}},
|
||||||
p2ptest.Exchange{Label: "repeated module handshake", Triggers: []p2ptest.Trigger{p2ptest.Trigger{Code: 1, Msg: &hs0{1}, Peer: a}}},
|
{Label: "repeated module handshake", Triggers: []p2ptest.Trigger{{Code: 1, Msg: &hs0{1}, Peer: a}}},
|
||||||
p2ptest.Exchange{Label: "receiving repeated module handshake", Expects: []p2ptest.Expect{p2ptest.Expect{Code: 1, Msg: &hs0{43}, Peer: a}}}}
|
{Label: "receiving repeated module handshake", Expects: []p2ptest.Expect{{Code: 1, Msg: &hs0{43}, Peer: a}}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiplePeers(t *testing.T, peer int, errs ...error) {
|
func runMultiplePeers(t *testing.T, peer int, errs ...error) {
|
||||||
|
|
@ -327,7 +327,7 @@ func runMultiplePeers(t *testing.T, peer int, errs ...error) {
|
||||||
// peer 0 sends kill request for peer with index <peer>
|
// peer 0 sends kill request for peer with index <peer>
|
||||||
s.TestExchanges(p2ptest.Exchange{
|
s.TestExchanges(p2ptest.Exchange{
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 2,
|
Code: 2,
|
||||||
Msg: &kill{s.IDs[peer]},
|
Msg: &kill{s.IDs[peer]},
|
||||||
Peer: s.IDs[0],
|
Peer: s.IDs[0],
|
||||||
|
|
@ -338,7 +338,7 @@ func runMultiplePeers(t *testing.T, peer int, errs ...error) {
|
||||||
// the peer not killed sends a drop request
|
// the peer not killed sends a drop request
|
||||||
s.TestExchanges(p2ptest.Exchange{
|
s.TestExchanges(p2ptest.Exchange{
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 3,
|
Code: 3,
|
||||||
Msg: &drop{},
|
Msg: &drop{},
|
||||||
Peer: s.IDs[(peer+1)%2],
|
Peer: s.IDs[(peer+1)%2],
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ concurrent routines,
|
||||||
Pot
|
Pot
|
||||||
* retrieval, insertion and deletion by key involves log(n) pointer lookups
|
* retrieval, insertion and deletion by key involves log(n) pointer lookups
|
||||||
* for any item retrieval (defined as common prefix on the binary key)
|
* for any item retrieval (defined as common prefix on the binary key)
|
||||||
* provide syncronous iterators respecting proximity ordering wrt any item
|
* provide synchronous iterators respecting proximity ordering wrt any item
|
||||||
* provide asyncronous iterator (for parallel execution of operations) over n items
|
* provide asynchronous iterator (for parallel execution of operations) over n items
|
||||||
* allows cheap iteration over ranges
|
* allows cheap iteration over ranges
|
||||||
* asymmetric concurrent merge (union)
|
* asymmetric concurrent merge (union)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ func (t *Pot) eachBin(val Val, pof Pof, po int, f func(int, int, func(func(val V
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EachNeighbour is a syncronous iterator over neighbours of any target val
|
// EachNeighbour is a synchronous iterator over neighbours of any target val
|
||||||
// the order of elements retrieved reflect proximity order to the target
|
// the order of elements retrieved reflect proximity order to the target
|
||||||
// TODO: add maximum proxbin to start range of iteration
|
// TODO: add maximum proxbin to start range of iteration
|
||||||
func (t *Pot) EachNeighbour(val Val, pof Pof, f func(Val, int) bool) bool {
|
func (t *Pot) EachNeighbour(val Val, pof Pof, f func(Val, int) bool) bool {
|
||||||
|
|
@ -615,7 +615,7 @@ func (t *Pot) eachNeighbour(val Val, pof Pof, f func(Val, int) bool) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// EachNeighbourAsync called on (val, max, maxPos, f, wait) is an asyncronous iterator
|
// EachNeighbourAsync called on (val, max, maxPos, f, wait) is an asynchronous iterator
|
||||||
// over elements not closer than maxPos wrt val.
|
// over elements not closer than maxPos wrt val.
|
||||||
// val does not need to be match an element of the Pot, but if it does, and
|
// val does not need to be match an element of the Pot, but if it does, and
|
||||||
// maxPos is keylength than it is included in the iteration
|
// maxPos is keylength than it is included in the iteration
|
||||||
|
|
@ -762,7 +762,7 @@ func (t *Pot) eachNeighbourAsync(val Val, pof Pof, max int, maxPos int, f func(V
|
||||||
|
|
||||||
// getPos called on (n) returns the forking node at PO n and its index if it exists
|
// getPos called on (n) returns the forking node at PO n and its index if it exists
|
||||||
// otherwise nil
|
// otherwise nil
|
||||||
// caller is suppoed to hold the lock
|
// caller is supposed to hold the lock
|
||||||
func (t *Pot) getPos(po int) (n *Pot, i int) {
|
func (t *Pot) getPos(po int) (n *Pot, i int) {
|
||||||
for i, n = range t.bins {
|
for i, n = range t.bins {
|
||||||
if po > n.po {
|
if po > n.po {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func TestDiscovery(t *testing.T) {
|
||||||
s.TestExchanges(p2ptest.Exchange{
|
s.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "outgoing SubPeersMsg",
|
Label: "outgoing SubPeersMsg",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 3,
|
Code: 3,
|
||||||
Msg: &subPeersMsg{Depth: 0},
|
Msg: &subPeersMsg{Depth: 0},
|
||||||
Peer: s.ProtocolTester.IDs[0],
|
Peer: s.ProtocolTester.IDs[0],
|
||||||
|
|
|
||||||
|
|
@ -424,7 +424,7 @@ func (k *Kademlia) callable(val pot.Val) OverlayAddr {
|
||||||
return e.addr()
|
return e.addr()
|
||||||
}
|
}
|
||||||
|
|
||||||
// BaseAddr return the kademlia base addres
|
// BaseAddr return the kademlia base address
|
||||||
func (k *Kademlia) BaseAddr() []byte {
|
func (k *Kademlia) BaseAddr() []byte {
|
||||||
return k.base
|
return k.base
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ func NewBzzTestPeer(p *protocols.Peer, addr *BzzAddr) *BzzPeer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Off returns the overlay peer record for offline persistance
|
// Off returns the overlay peer record for offline persistence
|
||||||
func (p *BzzPeer) Off() OverlayAddr {
|
func (p *BzzPeer) Off() OverlayAddr {
|
||||||
return p.BzzAddr
|
return p.BzzAddr
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,18 +70,18 @@ func (t *testStore) Save(key string, v []byte) error {
|
||||||
func HandshakeMsgExchange(lhs, rhs *HandshakeMsg, id discover.NodeID) []p2ptest.Exchange {
|
func HandshakeMsgExchange(lhs, rhs *HandshakeMsg, id discover.NodeID) []p2ptest.Exchange {
|
||||||
|
|
||||||
return []p2ptest.Exchange{
|
return []p2ptest.Exchange{
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: lhs,
|
Msg: lhs,
|
||||||
Peer: id,
|
Peer: id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
p2ptest.Exchange{
|
{
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: rhs,
|
Msg: rhs,
|
||||||
Peer: id,
|
Peer: id,
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ func TestStreamerRetrieveRequest(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "RetrieveRequestMsg",
|
Label: "RetrieveRequestMsg",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 5,
|
Code: 5,
|
||||||
Msg: &RetrieveRequestMsg{
|
Msg: &RetrieveRequestMsg{
|
||||||
Key: hash0[:],
|
Key: hash0[:],
|
||||||
|
|
@ -97,7 +97,7 @@ func TestStreamerUpstreamRetrieveRequestMsgExchangeWithoutStore(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "RetrieveRequestMsg",
|
Label: "RetrieveRequestMsg",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 5,
|
Code: 5,
|
||||||
Msg: &RetrieveRequestMsg{
|
Msg: &RetrieveRequestMsg{
|
||||||
Key: chunk.Key[:],
|
Key: chunk.Key[:],
|
||||||
|
|
@ -106,7 +106,7 @@ func TestStreamerUpstreamRetrieveRequestMsgExchangeWithoutStore(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &OfferedHashesMsg{
|
Msg: &OfferedHashesMsg{
|
||||||
HandoverProof: nil,
|
HandoverProof: nil,
|
||||||
|
|
@ -154,7 +154,7 @@ func TestStreamerUpstreamRetrieveRequestMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "RetrieveRequestMsg",
|
Label: "RetrieveRequestMsg",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 5,
|
Code: 5,
|
||||||
Msg: &RetrieveRequestMsg{
|
Msg: &RetrieveRequestMsg{
|
||||||
Key: hash,
|
Key: hash,
|
||||||
|
|
@ -163,7 +163,7 @@ func TestStreamerUpstreamRetrieveRequestMsgExchange(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &OfferedHashesMsg{
|
Msg: &OfferedHashesMsg{
|
||||||
HandoverProof: &HandoverProof{
|
HandoverProof: &HandoverProof{
|
||||||
|
|
@ -194,7 +194,7 @@ func TestStreamerUpstreamRetrieveRequestMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "RetrieveRequestMsg",
|
Label: "RetrieveRequestMsg",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 5,
|
Code: 5,
|
||||||
Msg: &RetrieveRequestMsg{
|
Msg: &RetrieveRequestMsg{
|
||||||
Key: hash,
|
Key: hash,
|
||||||
|
|
@ -204,7 +204,7 @@ func TestStreamerUpstreamRetrieveRequestMsgExchange(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 6,
|
Code: 6,
|
||||||
Msg: &ChunkDeliveryMsg{
|
Msg: &ChunkDeliveryMsg{
|
||||||
Key: hash,
|
Key: hash,
|
||||||
|
|
@ -256,7 +256,7 @@ func TestStreamerDownstreamChunkDeliveryMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "Subscribe message",
|
Label: "Subscribe message",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 4,
|
Code: 4,
|
||||||
Msg: &SubscribeMsg{
|
Msg: &SubscribeMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -272,7 +272,7 @@ func TestStreamerDownstreamChunkDeliveryMsgExchange(t *testing.T) {
|
||||||
p2ptest.Exchange{
|
p2ptest.Exchange{
|
||||||
Label: "ChunkDeliveryRequest message",
|
Label: "ChunkDeliveryRequest message",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 6,
|
Code: 6,
|
||||||
Msg: &ChunkDeliveryMsg{
|
Msg: &ChunkDeliveryMsg{
|
||||||
Key: chunkKey,
|
Key: chunkKey,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ var (
|
||||||
errClientNotFound = errors.New("client not found")
|
errClientNotFound = errors.New("client not found")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Peer is the Peer extention for the streaming protocol
|
// Peer is the Peer extension for the streaming protocol
|
||||||
type Peer struct {
|
type Peer struct {
|
||||||
*protocols.Peer
|
*protocols.Peer
|
||||||
streamer *Registry
|
streamer *Registry
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func TestStreamerDownstreamSubscribeUnsubscribeMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "Subscribe message",
|
Label: "Subscribe message",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 4,
|
Code: 4,
|
||||||
Msg: &SubscribeMsg{
|
Msg: &SubscribeMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -139,7 +139,7 @@ func TestStreamerDownstreamSubscribeUnsubscribeMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "Unsubscribe message",
|
Label: "Unsubscribe message",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &UnsubscribeMsg{
|
Msg: &UnsubscribeMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -173,7 +173,7 @@ func TestStreamerUpstreamSubscribeUnsubscribeMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "Subscribe message",
|
Label: "Subscribe message",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 4,
|
Code: 4,
|
||||||
Msg: &SubscribeMsg{
|
Msg: &SubscribeMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -186,7 +186,7 @@ func TestStreamerUpstreamSubscribeUnsubscribeMsgExchange(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &OfferedHashesMsg{
|
Msg: &OfferedHashesMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -210,7 +210,7 @@ func TestStreamerUpstreamSubscribeUnsubscribeMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "unsubscribe message",
|
Label: "unsubscribe message",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: &UnsubscribeMsg{
|
Msg: &UnsubscribeMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -244,7 +244,7 @@ func TestStreamerUpstreamSubscribeErrorMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "Subscribe message",
|
Label: "Subscribe message",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 4,
|
Code: 4,
|
||||||
Msg: &SubscribeMsg{
|
Msg: &SubscribeMsg{
|
||||||
Stream: "bar",
|
Stream: "bar",
|
||||||
|
|
@ -257,7 +257,7 @@ func TestStreamerUpstreamSubscribeErrorMsgExchange(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 7,
|
Code: 7,
|
||||||
Msg: &SubscribeErrorMsg{
|
Msg: &SubscribeErrorMsg{
|
||||||
Error: "stream bar not registered",
|
Error: "stream bar not registered",
|
||||||
|
|
@ -295,7 +295,7 @@ func TestStreamerDownstreamOfferedHashesMsgExchange(t *testing.T) {
|
||||||
err = tester.TestExchanges(p2ptest.Exchange{
|
err = tester.TestExchanges(p2ptest.Exchange{
|
||||||
Label: "Subscribe message",
|
Label: "Subscribe message",
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 4,
|
Code: 4,
|
||||||
Msg: &SubscribeMsg{
|
Msg: &SubscribeMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
@ -311,7 +311,7 @@ func TestStreamerDownstreamOfferedHashesMsgExchange(t *testing.T) {
|
||||||
p2ptest.Exchange{
|
p2ptest.Exchange{
|
||||||
Label: "WantedHashes message",
|
Label: "WantedHashes message",
|
||||||
Triggers: []p2ptest.Trigger{
|
Triggers: []p2ptest.Trigger{
|
||||||
p2ptest.Trigger{
|
{
|
||||||
Code: 1,
|
Code: 1,
|
||||||
Msg: &OfferedHashesMsg{
|
Msg: &OfferedHashesMsg{
|
||||||
HandoverProof: &HandoverProof{
|
HandoverProof: &HandoverProof{
|
||||||
|
|
@ -326,7 +326,7 @@ func TestStreamerDownstreamOfferedHashesMsgExchange(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Expects: []p2ptest.Expect{
|
Expects: []p2ptest.Expect{
|
||||||
p2ptest.Expect{
|
{
|
||||||
Code: 2,
|
Code: 2,
|
||||||
Msg: &WantedHashesMsg{
|
Msg: &WantedHashesMsg{
|
||||||
Stream: "foo",
|
Stream: "foo",
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ func (self *HandshakeController) cleanHandshake(pubkeyid string, topic *Topic, i
|
||||||
func (self *HandshakeController) clean() {
|
func (self *HandshakeController) clean() {
|
||||||
peerpubkeys := self.handshakes
|
peerpubkeys := self.handshakes
|
||||||
for pubkeyid, peertopics := range peerpubkeys {
|
for pubkeyid, peertopics := range peerpubkeys {
|
||||||
for topic, _ := range peertopics {
|
for topic := range peertopics {
|
||||||
self.cleanHandshake(pubkeyid, &topic, true, true)
|
self.cleanHandshake(pubkeyid, &topic, true, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -475,7 +475,7 @@ func (self *HandshakeAPI) AddHandshake(topic Topic) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deactivate handshake functionalty on a topic
|
// Deactivate handshake functionality on a topic
|
||||||
func (self *HandshakeAPI) RemoveHandshake(topic *Topic) error {
|
func (self *HandshakeAPI) RemoveHandshake(topic *Topic) error {
|
||||||
if _, ok := self.ctrl.deregisterFuncs[*topic]; ok {
|
if _, ok := self.ctrl.deregisterFuncs[*topic]; ok {
|
||||||
self.ctrl.deregisterFuncs[*topic]()
|
self.ctrl.deregisterFuncs[*topic]()
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ var pssSpec = &protocols.Spec{
|
||||||
|
|
||||||
func (self *Pss) Protocols() []p2p.Protocol {
|
func (self *Pss) Protocols() []p2p.Protocol {
|
||||||
return []p2p.Protocol{
|
return []p2p.Protocol{
|
||||||
p2p.Protocol{
|
{
|
||||||
Name: pssSpec.Name,
|
Name: pssSpec.Name,
|
||||||
Version: pssSpec.Version,
|
Version: pssSpec.Version,
|
||||||
Length: pssSpec.Length(),
|
Length: pssSpec.Length(),
|
||||||
|
|
@ -209,7 +209,7 @@ func (self *Pss) Run(p *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||||
|
|
||||||
func (self *Pss) APIs() []rpc.API {
|
func (self *Pss) APIs() []rpc.API {
|
||||||
apis := []rpc.API{
|
apis := []rpc.API{
|
||||||
rpc.API{
|
{
|
||||||
Namespace: "pss",
|
Namespace: "pss",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewAPI(self),
|
Service: NewAPI(self),
|
||||||
|
|
@ -418,7 +418,7 @@ func (self *Pss) generateSymmetricKey(topic Topic, address *PssAddress, addToCac
|
||||||
// If addtocache is set to true, the key will be added to the cache of keys
|
// If addtocache is set to true, the key will be added to the cache of keys
|
||||||
// used to attempt symmetric decryption of incoming messages.
|
// used to attempt symmetric decryption of incoming messages.
|
||||||
//
|
//
|
||||||
// Returns a string id that can be used to retreive the key bytes
|
// Returns a string id that can be used to retrieve the key bytes
|
||||||
// from the whisper backend (see pss.GetSymmetricKey())
|
// from the whisper backend (see pss.GetSymmetricKey())
|
||||||
func (self *Pss) SetSymmetricKey(key []byte, topic Topic, address *PssAddress, addtocache bool) (string, error) {
|
func (self *Pss) SetSymmetricKey(key []byte, topic Topic, address *PssAddress, addtocache bool) (string, error) {
|
||||||
keyid, err := self.w.AddSymKeyDirect(key)
|
keyid, err := self.w.AddSymKeyDirect(key)
|
||||||
|
|
|
||||||
|
|
@ -858,7 +858,7 @@ func benchmarkSymKeySend(b *testing.B) {
|
||||||
}
|
}
|
||||||
symkey, err := ps.w.GetSymKey(symkeyid)
|
symkey, err := ps.w.GetSymKey(symkeyid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("could not retreive symkey: %v", err)
|
b.Fatalf("could not retrieve symkey: %v", err)
|
||||||
}
|
}
|
||||||
ps.SetSymmetricKey(symkey, topic, &to, false)
|
ps.SetSymmetricKey(symkey, topic, &to, false)
|
||||||
|
|
||||||
|
|
@ -951,7 +951,7 @@ func benchmarkSymkeyBruteforceChangeaddr(b *testing.B) {
|
||||||
}
|
}
|
||||||
symkey, err := ps.w.GetSymKey(keyid)
|
symkey, err := ps.w.GetSymKey(keyid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("could not retreive symkey %s: %v", keyid, err)
|
b.Fatalf("could not retrieve symkey %s: %v", keyid, err)
|
||||||
}
|
}
|
||||||
wparams := &whisper.MessageParams{
|
wparams := &whisper.MessageParams{
|
||||||
TTL: defaultWhisperTTL,
|
TTL: defaultWhisperTTL,
|
||||||
|
|
@ -1035,7 +1035,7 @@ func benchmarkSymkeyBruteforceSameaddr(b *testing.B) {
|
||||||
}
|
}
|
||||||
symkey, err := ps.w.GetSymKey(keyid)
|
symkey, err := ps.w.GetSymKey(keyid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("could not retreive symkey %s: %v", keyid, err)
|
b.Fatalf("could not retrieve symkey %s: %v", keyid, err)
|
||||||
}
|
}
|
||||||
wparams := &whisper.MessageParams{
|
wparams := &whisper.MessageParams{
|
||||||
TTL: defaultWhisperTTL,
|
TTL: defaultWhisperTTL,
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ type DbStore struct {
|
||||||
|
|
||||||
// TODO: Instead of passing the distance function, just pass the address from which distances are calculated
|
// TODO: Instead of passing the distance function, just pass the address from which distances are calculated
|
||||||
// to avoid the appearance of a pluggable distance metric and opportunities of bugs associated with providing
|
// to avoid the appearance of a pluggable distance metric and opportunities of bugs associated with providing
|
||||||
// a function diferent from the one that is actually used.
|
// a function different from the one that is actually used.
|
||||||
func NewDbStore(path string, hash SwarmHasher, capacity uint64, po func(Key) uint8) (s *DbStore, err error) {
|
func NewDbStore(path string, hash SwarmHasher, capacity uint64, po func(Key) uint8) (s *DbStore, err error) {
|
||||||
s = new(DbStore)
|
s = new(DbStore)
|
||||||
s.hashfunc = hash
|
s.hashfunc = hash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue