Repository: hashgraph/hedera-mirror-node
Issue: When address book, that is larger than a single transaction, is updated - mirror node stops processing

**Detailed Description**

Mainnet mirror node stopped processing (and could not continue processing after restart) when it encountered an address book update that was larger than a single transaction.

The address book update in mainnet was a FILEUPDATE followed by 2 FILEAPPEND operations. This broke the mirrornode and stopped all processing.

The log messages were: 
```
	at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:209) ~[protobuf-java-3.5.1.jar:?]
	at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:214) ~[protobuf-java-3.5.1.jar:?]
	at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49) ~[protobuf-java-3.5.1.jar:?]
	at com.hederahashgraph.api.proto.java.NodeAddressBook.parseFrom(NodeAddressBook.java:237) ~[hedera-protobuf-java-api-0.3.4.jar:?]
	at com.hedera.signatureVerifier.NodeSignatureVerifier.<init>(NodeSignatureVerifier.java:62) [mirrorNode.jar:?]
	at com.hedera.downloader.RecordFileDownloader.verifySigsAndDownloadRecordFiles(RecordFileDownloader.java:136) [mirrorNode.jar:?]
	at com.hedera.downloader.RecordFileDownloader.downloadNewRecordfiles(RecordFileDownloader.java:65) [mirrorNode.jar:?]
	at com.hedera.downloader.RecordFileDownloader.main(RecordFileDownloader.java:82) [mirrorNode.jar:?]
```

**Actual Behavior**

**Expected Behavior**

**Environment:**

**Additional Context**

Changed files:
src/main/java/com/hedera/addressBook/NetworkAddressBook.java, src/main/java/com/hedera/recordFileLogger/RecordFileLogger.java

diff --git a/src/main/java/com/hedera/addressBook/NetworkAddressBook.java b/src/main/java/com/hedera/addressBook/NetworkAddressBook.java
index 763ac2ee5..3d075ee18 100644
--- a/src/main/java/com/hedera/addressBook/NetworkAddressBook.java
+++ b/src/main/java/com/hedera/addressBook/NetworkAddressBook.java
@@ -22,6 +22,7 @@ package com.hedera.addressBook;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map;
 
 import com.hedera.configLoader.ConfigLoader;
@@ -33,6 +34,7 @@ import com.hedera.hashgraph.sdk.HederaNetworkException;
 import com.hedera.hashgraph.sdk.account.AccountId;
 import com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey;
 import com.hedera.hashgraph.sdk.file.FileId;
+import com.hederahashgraph.api.proto.java.NodeAddressBook;
 
 import io.github.cdimascio.dotenv.Dotenv;
 
@@ -50,6 +52,7 @@ public class NetworkAddressBook {
 
 	static Client client;
 	static Dotenv dotenv = Dotenv.configure().ignoreIfMissing().load();
+    static byte[] addressBookBytes = new byte[0];
     
     public static void main(String[] args) {
 
@@ -62,8 +65,7 @@ public class NetworkAddressBook {
                     .setFileId(new FileId(0, 0, 102))
                     .execute();
 
-            writeFile(contents.getFileContents().getContents().toByteArray());
-			log.info("New address book successfully saved to {}", addressBookFile);
+            update(contents.getFileContents().getContents().toByteArray());
         } catch (FileNotFoundException e) {
     		log.error("Address book file {} not found.", addressBookFile);
         } catch (IOException e) {
@@ -75,10 +77,23 @@ public class NetworkAddressBook {
 		}
 	}
 
-    public static void writeFile(byte[] newContents) throws IOException {
+    public static void update(byte[] newContents) throws IOException {
+    	addressBookBytes = newContents;
+		savetoDisk();
+    }
+
+    public static void append(byte[] extraContents) throws IOException {
+    	byte[] newAddressBook = Arrays.copyOf(addressBookBytes, addressBookBytes.length + extraContents.length);
+    	System.arraycopy(extraContents, 0, newAddressBook, addressBookBytes.length, extraContents.length);
+    	addressBookBytes = newAddressBook;
+		savetoDisk();
+    }
+
+    private static void savetoDisk() throws IOException {
         FileOutputStream fos = new FileOutputStream(addressBookFile);
-        fos.write(newContents);
+        fos.write(addressBookBytes);
         fos.close();
+		log.info("New address book successfully saved to {}", addressBookFile);
     }
     
 	private static Client createHederaClient() {
diff --git a/src/main/java/com/hedera/recordFileLogger/RecordFileLogger.java b/src/main/java/com/hedera/recordFileLogger/RecordFileLogger.java
index 7405686b3..939587269 100644
--- a/src/main/java/com/hedera/recordFileLogger/RecordFileLogger.java
+++ b/src/main/java/com/hedera/recordFileLogger/RecordFileLogger.java
@@ -645,6 +645,15 @@ public class RecordFileLogger {
                     if ( ! bSkip) {
                     	sqlInsertFileData.addBatch();
                     }
+                    
+                	// update the local address book
+                	FileID updatedFile = body.getFileAppend().getFileID();
+
+                	if ((updatedFile.getFileNum() == 102) && (updatedFile.getShardNum() == 0) && (updatedFile.getRealmNum() == 0)) {
+                		// we have an address book update, refresh the local file
+                		NetworkAddressBook.append(contents);
+                	}
+                    
             	}
             } else if (body.hasFileCreate()) {
             	if (ConfigLoader.getPersistFiles().contentEquals("ALL") || (ConfigLoader.getPersistFiles().contentEquals("SYSTEM") && txRecord.getReceipt().getFileID().getFileNum() < 1000)) {
@@ -673,7 +682,7 @@ public class RecordFileLogger {
 
             	if ((updatedFile.getFileNum() == 102) && (updatedFile.getShardNum() == 0) && (updatedFile.getRealmNum() == 0)) {
             		// we have an address book update, refresh the local file
-            		NetworkAddressBook.writeFile(body.getFileUpdate().getContents().toByteArray());
+            		NetworkAddressBook.update(body.getFileUpdate().getContents().toByteArray());
             	}
 
             } else if (body.hasFreeze()) {