ames: use +trace to print logs

This commit is contained in:
yosoyubik 2022-04-22 10:06:53 +02:00
parent e2f8e21529
commit 087f24e931
2 changed files with 22 additions and 30 deletions

View File

@ -1220,8 +1220,8 @@
?~ parsed=(parse-bone-wire wire)
:: no-op
::
=/ =tape "ames dropping malformed wire: {(spud wire)}"
(emit duct %pass /malformed-wire %d %flog %text tape)
~> %slog.0^leaf/"ames: dropping malformed wire: {(spud wire)}"
event-core
?> ?=([@ her=ship *] u.parsed)
=* her her.u.parsed
=/ =peer-state (got-peer-state her)
@ -1233,20 +1233,19 @@
==
:: ignore events from an old rift
::
?. odd.veb event-core
(log "ames dropping old rift wire: {(spud wire)}")
%- %^ trace odd.veb her
|.("dropping old rift wire: {(spud wire)}")
event-core
=/ =bone
?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed)
=? event-core.peer-core &(odd.veb ?=([%old *] u.parsed))
(log "ames parsing old wire format: {(spud wire)}")
=? peer-core ?=([%old *] u.parsed)
%- %^ trace odd.veb her
|.("parsing old wire: {(spud wire)}")
peer-core
?~ error
(send-ack bone)
(send-nack bone u.error)
::
++ log
|= =tape
^+ event-core
(emit duct %pass /on-take-done-parse-wire %d %flog %text tape)
:: if processing succeded, send positive ack packet and exit
::
++ send-ack
@ -1525,9 +1524,9 @@
++ on-take-boon
|= [=wire payload=*]
^+ event-core
|^
?~ parsed=(parse-bone-wire wire)
(log "ames dropping malformed wire: {(spud wire)}")
~> %slog.0^leaf/"ames: dropping malformed wire: {(spud wire)}"
event-core
::
?> ?=([@ her=ship *] u.parsed)
=* her her.u.parsed
@ -1540,19 +1539,16 @@
==
:: ignore events from an old rift
::
?. odd.veb event-core
(log "ames dropping old rift wire: {(spud wire)}")
%- %^ trace odd.veb her
|.("dropping old rift wire: {(spud wire)}")
event-core
=/ =bone
?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed)
=? event-core.peer-core &(odd.veb ?=([%old *] u.parsed))
(log "ames parsing old wire: {(spud wire)}")
=? peer-core ?=([%old *] u.parsed)
%- %^ trace odd.veb her
|.("parsing old wire: {(spud wire)}")
peer-core
abet:(on-memo:peer-core bone payload %boon)
::
++ log
|= =tape
^+ event-core
(emit duct %pass /on-take-boon-parse-wire %d %flog %text tape)
--
:: +on-plea: handle request to send message
::
++ on-plea

View File

@ -341,9 +341,8 @@
=^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1))
=^ moves3 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~)
%+ expect-eq
!> :^ ~[//unix] %pass /on-take-done-parse-wire
[%d %flog %text "ames parsing old wire format: /bone/~nec/1"]
!> (snag 0 `(list move:ames)`moves3)
!> 1
!> (lent `(list move:ames)`moves3)
::
++ test-dangling-bone ^- tang
=^ moves0 bud (call bud ~[/g/hood] %spew [%odd]~)
@ -359,15 +358,12 @@
^- sign:ames
[%jael %public-keys %diff who=~nec %rift from=0 to=1]
:: %gall has a pending wire with the old rift, so sending a gift to
:: %ames on it will drop that request, and print a message to the user
:: %ames on it will drop that request, not producing any moves
::
=^ moves3 bud (take bud /bone/~nec/0/1 ~[//unix] %g %done ~)
::
%+ expect-eq
!> %- sy
:_ ~
:^ ~[//unix] %pass /on-take-done-parse-wire
[%d %flog %text "ames dropping old rift wire: /bone/~nec/0/1"]
!> ~
!> (sy ,.moves3)
::
++ test-ames-flow-with-new-rift ^- tang