@@ -833,8 +833,14 @@ impl<ChanSigner: ChannelKeys> PartialEq for ChannelMonitor<ChanSigner> {
833
833
}
834
834
835
835
impl < ChanSigner : ChannelKeys + Writeable > ChannelMonitor < ChanSigner > {
836
- /// Serializes into a vec, with various modes for the exposed pub fns
837
- fn write < W : Writer > ( & self , writer : & mut W , for_local_storage : bool ) -> Result < ( ) , :: std:: io:: Error > {
836
+ /// Writes this monitor into the given writer, suitable for writing to disk.
837
+ ///
838
+ /// Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
839
+ /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
840
+ /// the "reorg path" (ie not just starting at the same height but starting at the highest
841
+ /// common block that appears on your best chain as well as on the chain which contains the
842
+ /// last block hash returned) upon deserializing the object!
843
+ pub fn write_for_disk < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
838
844
//TODO: We still write out all the serialization here manually instead of using the fancy
839
845
//serialization framework we have, we should migrate things over to it.
840
846
writer. write_all ( & [ SERIALIZATION_VERSION ; 1 ] ) ?;
@@ -929,14 +935,10 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
929
935
}
930
936
}
931
937
932
- if for_local_storage {
933
- writer. write_all ( & byte_utils:: be64_to_array ( self . remote_hash_commitment_number . len ( ) as u64 ) ) ?;
934
- for ( ref payment_hash, commitment_number) in self . remote_hash_commitment_number . iter ( ) {
935
- writer. write_all ( & payment_hash. 0 [ ..] ) ?;
936
- writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
937
- }
938
- } else {
939
- writer. write_all ( & byte_utils:: be64_to_array ( 0 ) ) ?;
938
+ writer. write_all ( & byte_utils:: be64_to_array ( self . remote_hash_commitment_number . len ( ) as u64 ) ) ?;
939
+ for ( ref payment_hash, commitment_number) in self . remote_hash_commitment_number . iter ( ) {
940
+ writer. write_all ( & payment_hash. 0 [ ..] ) ?;
941
+ writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
940
942
}
941
943
942
944
macro_rules! serialize_local_tx {
@@ -977,17 +979,8 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
977
979
writer. write_all ( & [ 0 ; 1 ] ) ?;
978
980
}
979
981
980
- if for_local_storage {
981
- writer. write_all ( & byte_utils:: be48_to_array ( self . current_remote_commitment_number ) ) ?;
982
- } else {
983
- writer. write_all ( & byte_utils:: be48_to_array ( 0 ) ) ?;
984
- }
985
-
986
- if for_local_storage {
987
- writer. write_all ( & byte_utils:: be48_to_array ( self . current_local_commitment_number ) ) ?;
988
- } else {
989
- writer. write_all ( & byte_utils:: be48_to_array ( 0 ) ) ?;
990
- }
982
+ writer. write_all ( & byte_utils:: be48_to_array ( self . current_remote_commitment_number ) ) ?;
983
+ writer. write_all ( & byte_utils:: be48_to_array ( self . current_local_commitment_number ) ) ?;
991
984
992
985
writer. write_all ( & byte_utils:: be64_to_array ( self . payment_preimages . len ( ) as u64 ) ) ?;
993
986
for payment_preimage in self . payment_preimages . values ( ) {
@@ -1039,28 +1032,6 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
1039
1032
1040
1033
Ok ( ( ) )
1041
1034
}
1042
-
1043
- /// Writes this monitor into the given writer, suitable for writing to disk.
1044
- ///
1045
- /// Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
1046
- /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
1047
- /// the "reorg path" (ie not just starting at the same height but starting at the highest
1048
- /// common block that appears on your best chain as well as on the chain which contains the
1049
- /// last block hash returned) upon deserializing the object!
1050
- pub fn write_for_disk < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
1051
- self . write ( writer, true )
1052
- }
1053
-
1054
- /// Encodes this monitor into the given writer, suitable for sending to a remote watchtower
1055
- ///
1056
- /// Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
1057
- /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
1058
- /// the "reorg path" (ie not just starting at the same height but starting at the highest
1059
- /// common block that appears on your best chain as well as on the chain which contains the
1060
- /// last block hash returned) upon deserializing the object!
1061
- pub fn write_for_watchtower < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
1062
- self . write ( writer, false )
1063
- }
1064
1035
}
1065
1036
1066
1037
impl < ChanSigner : ChannelKeys > ChannelMonitor < ChanSigner > {
0 commit comments