-
Notifications
You must be signed in to change notification settings - Fork 282
Extended Queries: use TLV format for optional data #1072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pm47
merged 16 commits into
extended-queries-optional
from
extended-queries-optional-tlv2
Aug 22, 2019
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1342621
Extended Queries: use TLV format for optional data
sstone bdd0322
Merge branch 'master' into extended-queries-optional-tlv2
sstone 3581e36
Move query message TLVs to their own namespace
sstone 1b0160c
Optional TLVs are represented as a list, not an optional list
sstone 6deaaa3
Update to match BOLT PR
sstone ecd8a2b
Merge branch 'master' into extended-queries-optional-tlv2
sstone 787fd01
Merge branch 'extended-queries-optional' into extended-queries-option…
sstone 8dfdf09
TLV Stream: Implement a generic "get" method for TLV fields
sstone 247355b
Extended range queries: Implement latest BOLT changes
sstone f3f213f
Merge branch 'master' into extended-queries-optional-tlv2
sstone d644e4b
Use extended range queries on regtest and testnet
sstone ddcf007
Merge branch 'extended-queries-optional' into extended-queries-option…
sstone b0c2dbc
Address review comments
sstone c212d9b
Router: rework handling of ReplyChannelRange
sstone b485308
NodeParams: move fee base check to its proper place
sstone 94362f1
Router: minor cleanup
sstone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 82 additions & 45 deletions
127
eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
eclair-core/src/main/scala/fr/acinq/eclair/wire/QueryChannelRangeTlv.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package fr.acinq.eclair.wire | ||
|
|
||
| import fr.acinq.eclair.UInt64 | ||
| import fr.acinq.eclair.wire.CommonCodecs.{shortchannelid, varint, varintoverflow} | ||
| import scodec.Codec | ||
| import scodec.codecs._ | ||
|
|
||
| sealed trait QueryChannelRangeTlv extends Tlv | ||
|
|
||
| object QueryChannelRangeTlv { | ||
| /** | ||
| * Optional query flag that is appended to QueryChannelRange | ||
| * @param flag bit 1 set means I want timestamps, bit 2 set means I want checksums | ||
| */ | ||
| case class QueryFlags(flag: Long) extends QueryChannelRangeTlv { | ||
| val wantTimestamps = QueryFlags.wantTimestamps(flag) | ||
|
|
||
| val wantChecksums = QueryFlags.wantChecksums(flag) | ||
| } | ||
|
|
||
| case object QueryFlags { | ||
| val WANT_TIMESTAMPS: Long = 1 | ||
| val WANT_CHECKSUMS: Long = 2 | ||
| val WANT_ALL: Long = (WANT_TIMESTAMPS | WANT_CHECKSUMS) | ||
|
|
||
| def wantTimestamps(flag: Long) = (flag & WANT_TIMESTAMPS) != 0 | ||
|
|
||
| def wantChecksums(flag: Long) = (flag & WANT_CHECKSUMS) != 0 | ||
| } | ||
|
|
||
| val queryFlagsCodec: Codec[QueryFlags] = Codec(("flag" | varintoverflow)).as[QueryFlags] | ||
|
|
||
| val codec: Codec[TlvStream[QueryChannelRangeTlv]] = TlvCodecs.tlvStream(discriminated.by(varint) | ||
| .typecase(UInt64(1), variableSizeBytesLong(varintoverflow, queryFlagsCodec)) | ||
| ) | ||
|
|
||
| } |
41 changes: 41 additions & 0 deletions
41
eclair-core/src/main/scala/fr/acinq/eclair/wire/QueryShortChannelIdsTlv.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package fr.acinq.eclair.wire | ||
|
|
||
| import fr.acinq.eclair.UInt64 | ||
| import fr.acinq.eclair.wire.CommonCodecs.{shortchannelid, varint, varintoverflow} | ||
| import scodec.Codec | ||
| import scodec.codecs.{byte, discriminated, list, provide, variableSizeBytesLong, zlib} | ||
|
|
||
| sealed trait QueryShortChannelIdsTlv extends Tlv | ||
|
|
||
| object QueryShortChannelIdsTlv { | ||
|
|
||
| /** | ||
| * Optional TLV-based query message that can be appended to QueryShortChannelIds | ||
| * @param encoding 0 means uncompressed, 1 means compressed with zlib | ||
| * @param array array of query flags, each flags specifies the info we want for a given channel | ||
| */ | ||
| case class EncodedQueryFlags(encoding: EncodingType, array: List[Long]) extends QueryShortChannelIdsTlv | ||
|
|
||
| case object QueryFlagType { | ||
| val INCLUDE_CHANNEL_ANNOUNCEMENT: Long = 1 | ||
| val INCLUDE_CHANNEL_UPDATE_1: Long = 2 | ||
| val INCLUDE_CHANNEL_UPDATE_2: Long = 4 | ||
| val INCLUDE_ALL: Long = (INCLUDE_CHANNEL_ANNOUNCEMENT | INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2) | ||
|
|
||
| def includeAnnouncement(flag: Long) = (flag & INCLUDE_CHANNEL_ANNOUNCEMENT) != 0 | ||
|
|
||
| def includeUpdate1(flag: Long) = (flag & INCLUDE_CHANNEL_UPDATE_1) != 0 | ||
|
|
||
| def includeUpdate2(flag: Long) = (flag & INCLUDE_CHANNEL_UPDATE_2) != 0 | ||
| } | ||
|
|
||
| val encodedQueryFlagsCodec: Codec[EncodedQueryFlags] = | ||
| discriminated[EncodedQueryFlags].by(byte) | ||
| .\(0) { case a@EncodedQueryFlags(EncodingType.UNCOMPRESSED, _) => a }((provide[EncodingType](EncodingType.UNCOMPRESSED) :: list(varintoverflow)).as[EncodedQueryFlags]) | ||
| .\(1) { case a@EncodedQueryFlags(EncodingType.COMPRESSED_ZLIB, _) => a }((provide[EncodingType](EncodingType.COMPRESSED_ZLIB) :: zlib(list(varintoverflow))).as[EncodedQueryFlags]) | ||
|
|
||
|
|
||
| val codec: Codec[TlvStream[QueryShortChannelIdsTlv]] = TlvCodecs.tlvStream(discriminated.by(varint) | ||
| .typecase(UInt64(1), variableSizeBytesLong(varintoverflow, encodedQueryFlagsCodec)) | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.