Fixed PendingPayment methods to assign for add and delete
This commit is contained in:
@@ -41,8 +41,7 @@ func TestPing(t *testing.T) {
|
|||||||
log.T.S("received ping confirmation ID", cf)
|
log.T.S("received ping confirmation ID", cf)
|
||||||
quit.Q()
|
quit.Q()
|
||||||
}, os[len(os)-1].(*confirm.OnionSkin).ID)
|
}, os[len(os)-1].(*confirm.OnionSkin).ID)
|
||||||
o := os.Assemble()
|
b := wire.EncodeOnion(os.Assemble())
|
||||||
b := wire.EncodeOnion(o)
|
|
||||||
log.T.S("sending ping with ID", os[len(os)-1].(*confirm.OnionSkin))
|
log.T.S("sending ping with ID", os[len(os)-1].(*confirm.OnionSkin))
|
||||||
clients[0].Send(clients[0].Nodes[0].AddrPort, b)
|
clients[0].Send(clients[0].Nodes[0].AddrPort, b)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -104,8 +103,7 @@ func TestSendExit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
quit.Q()
|
quit.Q()
|
||||||
})
|
})
|
||||||
o := os.Assemble()
|
b := wire.EncodeOnion(os.Assemble())
|
||||||
b := wire.EncodeOnion(o)
|
|
||||||
log.T.Ln(clients[0].Node.AddrPort.String())
|
log.T.Ln(clients[0].Node.AddrPort.String())
|
||||||
clients[0].Node.Send(b)
|
clients[0].Node.Send(b)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -173,8 +171,7 @@ func TestSendKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
quit.Q()
|
quit.Q()
|
||||||
}, cnf)
|
}, cnf)
|
||||||
o := sk.Assemble()
|
b := wire.EncodeOnion(sk.Assemble())
|
||||||
b := wire.EncodeOnion(o)
|
|
||||||
clients[0].Send(clients[0].Nodes[0].AddrPort, b)
|
clients[0].Send(clients[0].Nodes[0].AddrPort, b)
|
||||||
<-quit.Wait()
|
<-quit.Wait()
|
||||||
for _, v := range clients {
|
for _, v := range clients {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ func (cl *Client) runner() (out bool) {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
if !topUp {
|
if !topUp {
|
||||||
cl.PendingPayments = cl.PendingPayments.Add(p)
|
cl.AddPendingPayment(p)
|
||||||
log.T.F("awaiting session keys for preimage %x",
|
log.T.F("awaiting session keys for preimage %x",
|
||||||
p.Preimage)
|
p.Preimage)
|
||||||
}
|
}
|
||||||
@@ -333,13 +333,12 @@ func (cl *Client) session(on *session.OnionSkin, b slice.Bytes,
|
|||||||
return fmt.Sprint("incoming session",
|
return fmt.Sprint("incoming session",
|
||||||
spew.Sdump(on.PreimageHash()))
|
spew.Sdump(on.PreimageHash()))
|
||||||
})
|
})
|
||||||
pi := cl.PendingPayments.FindPreimage(on.PreimageHash())
|
pi := cl.FindPendingPreimage(on.PreimageHash())
|
||||||
if pi != nil {
|
if pi != nil {
|
||||||
ss := node.NewSession(pi.ID,
|
cl.DeletePendingPayment(pi.Preimage)
|
||||||
cl.Node, pi.Amount, on.Header, on.Payload, on.Hop)
|
|
||||||
cl.AddSession(ss)
|
|
||||||
log.T.F("Adding session %x\n", pi.ID)
|
log.T.F("Adding session %x\n", pi.ID)
|
||||||
cl.PendingPayments = cl.PendingPayments.Delete(pi.Preimage)
|
cl.AddSession(node.NewSession(pi.ID,
|
||||||
|
cl.Node, pi.Amount, on.Header, on.Payload, on.Hop))
|
||||||
cl.Node.Send(BudgeUp(b, *c))
|
cl.Node.Send(BudgeUp(b, *c))
|
||||||
} else {
|
} else {
|
||||||
log.T.Ln("dropping session message without payment")
|
log.T.Ln("dropping session message without payment")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package node
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"sync"
|
sync "sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/indra-labs/indra"
|
"github.com/indra-labs/indra"
|
||||||
@@ -162,14 +162,14 @@ func (n *Node) AddPendingPayment(
|
|||||||
|
|
||||||
n.Lock()
|
n.Lock()
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
n.PendingPayments.Add(np)
|
n.PendingPayments = n.PendingPayments.Add(np)
|
||||||
}
|
}
|
||||||
func (n *Node) DeletePendingPayment(
|
func (n *Node) DeletePendingPayment(
|
||||||
preimage sha256.Hash) {
|
preimage sha256.Hash) {
|
||||||
|
|
||||||
n.Lock()
|
n.Lock()
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
n.PendingPayments.Delete(preimage)
|
n.PendingPayments = n.PendingPayments.Delete(preimage)
|
||||||
}
|
}
|
||||||
func (n *Node) FindPendingPayment(
|
func (n *Node) FindPendingPayment(
|
||||||
id nonce.ID) (pp *Payment) {
|
id nonce.ID) (pp *Payment) {
|
||||||
|
|||||||
Reference in New Issue
Block a user