-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add networks to init message (#1254)
- Loading branch information
Showing
7 changed files
with
136 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
49 changes: 49 additions & 0 deletions
49
eclair-core/src/main/scala/fr/acinq/eclair/wire/InitTlv.scala
This file contains 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,49 @@ | ||
/* | ||
* Copyright 2019 ACINQ SAS | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package fr.acinq.eclair.wire | ||
|
||
import fr.acinq.bitcoin.ByteVector32 | ||
import fr.acinq.eclair.UInt64 | ||
import fr.acinq.eclair.wire.CommonCodecs._ | ||
import scodec.Codec | ||
import scodec.codecs.{discriminated, list, variableSizeBytesLong} | ||
|
||
/** | ||
* Created by t-bast on 13/12/2019. | ||
*/ | ||
|
||
/** Tlv types used inside Init messages. */ | ||
sealed trait InitTlv extends Tlv | ||
|
||
object InitTlv { | ||
|
||
/** The chains the node is interested in. */ | ||
case class Networks(chainHashes: List[ByteVector32]) extends InitTlv | ||
|
||
} | ||
|
||
object InitTlvCodecs { | ||
|
||
import InitTlv._ | ||
|
||
private val networks: Codec[Networks] = variableSizeBytesLong(varintoverflow, list(bytes32)).as[Networks] | ||
|
||
val initTlvCodec = TlvCodecs.tlvStream(discriminated[InitTlv].by(varint) | ||
.typecase(UInt64(1), networks) | ||
) | ||
|
||
} |
This file contains 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 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 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 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 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