diff options
author | Bernd Fix <brf@hoi-polloi.org> | 2022-08-24 17:27:59 +0200 |
---|---|---|
committer | Bernd Fix <brf@hoi-polloi.org> | 2022-08-24 17:27:59 +0200 |
commit | 3cee953814e10b8e8bca10164e7f25e93f4a6d3f (patch) | |
tree | 83d57d9ee618881fcf77c0865f9d5c407e91307e /src/gnunet/service/dht/path/handling.go | |
parent | 21d7292dbd062ff11194fdc235a3d54830d7ba57 (diff) | |
download | gnunet-go-3cee953814e10b8e8bca10164e7f25e93f4a6d3f.tar.gz gnunet-go-3cee953814e10b8e8bca10164e7f25e93f4a6d3f.zip |
Integration tests: more bug fixes.v0.1.33
Diffstat (limited to 'src/gnunet/service/dht/path/handling.go')
-rw-r--r-- | src/gnunet/service/dht/path/handling.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gnunet/service/dht/path/handling.go b/src/gnunet/service/dht/path/handling.go index 7ad91df..38fce68 100644 --- a/src/gnunet/service/dht/path/handling.go +++ b/src/gnunet/service/dht/path/handling.go | |||
@@ -43,7 +43,7 @@ type Path struct { | |||
43 | NumList uint16 `order:"big"` // number of list entries | 43 | NumList uint16 `order:"big"` // number of list entries |
44 | SplitPos uint16 `order:"big"` // optional split position | 44 | SplitPos uint16 `order:"big"` // optional split position |
45 | List []*Entry `size:"NumList"` // list of path entries | 45 | List []*Entry `size:"NumList"` // list of path entries |
46 | LastSig *util.PeerSignature `opt:"(Isused)"` // last hop signature | 46 | LastSig *util.PeerSignature `opt:"(IsUsed)"` // last hop signature |
47 | LastHop *util.PeerID `opt:"(IsUsed)"` // last hop peer id | 47 | LastHop *util.PeerID `opt:"(IsUsed)"` // last hop peer id |
48 | } | 48 | } |
49 | 49 | ||
@@ -90,16 +90,21 @@ func (p *Path) Size() uint { | |||
90 | if p.TruncOrigin != nil { | 90 | if p.TruncOrigin != nil { |
91 | size += p.TruncOrigin.Size() | 91 | size += p.TruncOrigin.Size() |
92 | } | 92 | } |
93 | size += uint(p.NumList) * p.List[0].Size() | 93 | if p.NumList > 0 { |
94 | size += uint(p.NumList) * p.List[0].Size() | ||
95 | } | ||
94 | if p.LastSig != nil { | 96 | if p.LastSig != nil { |
95 | size += p.LastSig.Size() + p.LastHop.Size() | 97 | size += p.LastSig.Size() |
96 | } | 98 | } |
97 | return size | 99 | return size |
98 | } | 100 | } |
99 | 101 | ||
100 | // Bytes returns a binary representation | 102 | // Bytes returns a binary representation |
101 | func (p *Path) Bytes() []byte { | 103 | func (p *Path) Bytes() []byte { |
102 | buf, _ := data.Marshal(p) | 104 | buf, err := data.Marshal(p) |
105 | if err != nil { | ||
106 | logger.Println(logger.WARN, "[path] failed serialization: "+err.Error()) | ||
107 | } | ||
103 | return buf | 108 | return buf |
104 | } | 109 | } |
105 | 110 | ||