From 05022b730669aa0c837d572a6adc2456080f87cc Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Sun, 8 Nov 2020 15:34:29 -0600 Subject: [PATCH] Remove Lipmaaa references --- README.md | 5 +++-- fixtures/fixture.pgn | 13 ------------- fixtures/has_blobs/messages.pgn | 19 ++++++++----------- project/encoders.go | 1 - project/import_bundle.go | 5 +---- project/import_bundle_test.go | 6 +++--- project/migrations.go | 1 - project/parser.go | 6 +----- project/verify.go | 1 - 9 files changed, 16 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 96570bf..a0ebebe 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ Email `contact@vaporsoft.xyz` if you have any questions. # TODO + - [ ] Add forgery protection tests - [ ] Add a real testing lib to DRY things up. - - [ ] Validate and scrutinize `depth`, `lipmaa`, `prev` fields when ingesting message bundles to account for poorly written peer clients. + - [ ] Validate and scrutinize `depth`, `prev` fields when ingesting message bundles to account for poorly written peer clients. - [ ] Get a good CI system going? Run tests at PR time, provide prebuilt binaries, prevent coverage slips, etc.. - [ ] Add a `transact()` helper to ensure all transactions are closed out. - [ ] Switch to [SQLX](https://github.com/jmoiron/sqlx) for extra sanity. @@ -40,7 +41,7 @@ Email `contact@vaporsoft.xyz` if you have any questions. # Protocol Changes? - - [ ] Rename `lipmaa` to `backlink` as Bamboo protocol has done? + - [X] Just ditch `lipmaa` altogether in the name of time? - [ ] Don't enforce a structure on how blobs are packed into bundles- the client is forced to determine the SHA checksum regardless. Forced structure just complicates protocol design. - [ ] Mandate usage of ZIP files so that bundles are always a single file? diff --git a/fixtures/fixture.pgn b/fixtures/fixture.pgn index 86e90c8..8740a98 100644 --- a/fixtures/fixture.pgn +++ b/fixtures/fixture.pgn @@ -1,7 +1,6 @@ author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 0 kind FILE.ET9C7B9N82XR0F021CXEWSPDH23H4CHMX866WWA3R2PXEFZM67PG -lipmaa NONE prev NONE a:"b" @@ -11,7 +10,6 @@ signature TKVXZ5EJV0GRDY60V2ZHN4ART60FYYJ99SJQGXAK8AF80X1ZFQCR18P5JVJZWMFME5Q7WF author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 1 kind a -lipmaa NONE prev TEXT.0HG26KBTYFD3FW8K72GFJJ5CV9KXSDRG2WJS15P3XQ5V56XNX8E0 FILE.7Z2CSZKMB1RE5G6SKXRZ63ZGCNP8VVEM3K0XFMYKETRDQSM5WBSG:"b" @@ -21,7 +19,6 @@ signature DPBY0XEKZPMFT0DM7JFFZVPZG4FR248SQVAXJ7T3T7QB1QYV3MKKS1V9FHWK9P33MECKBE author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 2 kind a -lipmaa NONE prev TEXT.BJEPB3TPZM2ZSQWHYB4N5ECMF0S9H4VKH0WYE1QY5T911YYZEA5G b:FILE.HDDSVC617PS44NP856N3CJN91HPJXEHHHE93595BJC9VJN6KANFG @@ -31,7 +28,6 @@ signature P6DK52KZ2KWHDJJ7Y7GZA2VGDRNQ9FDBFTDJY1ME6V21BDCCKYMFF3TEZ5EENJMRR4B8NC author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 3 kind a8df9e36-7c32-431c-af4c-855b6c398c87 -lipmaa NONE prev TEXT.TCZ4GCD45ETX73EEGRHPFX1BBPNBG70S03GC6V0F2QE07SCQ18T0 foo:"fe3d0f08-13a3-47eb-b605-cc9c1dd1811c" @@ -41,7 +37,6 @@ signature R4RZ2DXD624C5TT0JCS1CP8ZA89KVMP8C2X39H7N0H6T4CPZNHGN5DA1B6B7B35V4WBB6X author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 4 kind dcf7d089-b5ef-4f8b-8fe7-c176e7c7605b -lipmaa TEXT.BJEPB3TPZM2ZSQWHYB4N5ECMF0S9H4VKH0WYE1QY5T911YYZEA5G prev TEXT.94NPGGDTM456TFBJTQH2YFSQ2W46AJ9GGVYYYGXHGTR9A27ZPG2G foo:"bar" @@ -51,7 +46,6 @@ signature 95TCVY0CP01NZVHQSR8CNXDGYW9BK4CJADXQGA1R5G5Y8HD05N8MZ4KTSSAGP785BXQYMY author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 5 kind 485d10d6-87b3-4f1f-baf3-752796afec64 -lipmaa NONE prev TEXT.HWR2DNDWJYP60348W0M78QF4H0B5B7X6NT6KVS9GNJSP207PDB9G foo:"16c4ad9b-34cc-4c37-a4c9-3ab0161ea4b5" @@ -61,7 +55,6 @@ signature 0NPJG4A0VWP0HPS2SV3DJH696QMWBWZZ27CKCTX5JK8WJ1JE818PPJGRJRAC4QQ7K10GT2 author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 6 kind 74be7129-06b8-4cb6-8aa9-d549710cd657 -lipmaa NONE prev TEXT.YEBFRRM6HCX514HBHBTB3AK2HF5B71MPDMB5HNQW4ACYETQYDNZ0 foo:"123" @@ -71,7 +64,6 @@ signature HD7VNKTMARQ3294C6KDGXV4BP0GKFWEXBC5R8RHWF8VKBMFXDB2NCX4XQN6Q524ZWPNTM0 author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 7 kind f06d3a2b-a1c0-4bf5-83e7-29409ac0c9b4 -lipmaa NONE prev TEXT.XQRKXB46M6HZAWTADNXWFTHQS8PGEPDZ581J40REFNT3YWG8YZ70 foo:"123" @@ -81,7 +73,6 @@ signature ZYHVXQGZ9G78AD69A9SFMF281B4WHX05AG8TEKBKSFH706HXNYRTPH9G5VP01ZC515MMP6 author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 8 kind a4df2c79-17ef-4c90-ba11-3021fe23269c -lipmaa TEXT.HWR2DNDWJYP60348W0M78QF4H0B5B7X6NT6KVS9GNJSP207PDB9G prev TEXT.49S2F3Y6AXHDD8F62RKXPFWC2BYBV5D16VQY34F40NTQFZW1R0G0 foo:"bar" @@ -91,7 +82,6 @@ signature W57NQEX8HD3DQG1F8G6SD8960QRP0HYPWXCKTN6AZ5SXZCWABPBWHM84EFDH5MJTJ4YYVZ author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 9 kind a2c49e15-befd-4a62-8a7d-f4a28d052c38 -lipmaa NONE prev TEXT.NRK3MEG982X5N76RFF4F9WC405452YNZFCH5WTP9G8ERRTYNN3V0 foo:"3b39df57-9dee-4a66-8d49-ee4944631f33" @@ -101,7 +91,6 @@ signature ATRMAPBKQ7VZWRDSX4ASSVZ3D9CKSS3PZ8ZP229H96MA9DGD7RM5TA1E4CZD42BWK6Q9XJ author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 10 kind 7a1a2b5a-32c2-4b3f-b287-42e4a73e340d -lipmaa NONE prev TEXT.FKH08FA04MCC7RPYN1GZZT0VAGHAW0VRHQD6QZX3C6YCTAZM9WE0 foo:"bar" @@ -111,7 +100,6 @@ signature 3F774WW8NVA3HAQRV7M4CWKBYH86QB8F9QPQ6FV96MG6S9KHBG519WKPNBZR7YRFFBWHZZ author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 11 kind c8cfac48-460f-47c6-a6b3-34daa431fcab -lipmaa NONE prev TEXT.DQH1TX6QM3223PNX4Y352AQSDJM91SMFYJFG6PPC182ZW9PYR70G foo:"450024fc-ea1c-4144-b7b9-16c60ff00e45" @@ -121,7 +109,6 @@ signature AT3VWBJXP7NZBGADPWGX0PVHPKS0W14SAY12XZHYQ3EF025641M29P46ZNYM3M4Q0HKZYH author USER.PJC0W5XRFX4JBFPX929PQETB58VM7A4P5RDMW7Y8E9P4CRZDWEBG depth 12 kind 6ecac9f1-e5dc-4274-a0fd-633c2cd56832 -lipmaa TEXT.NRK3MEG982X5N76RFF4F9WC405452YNZFCH5WTP9G8ERRTYNN3V0 prev TEXT.Y3K7WH4R9W9EBTZB27NJCYR6VBKYTHZX97Y05841VPM5G50ZYG00 foo:"fc1a7066-2af2-4437-98e3-dbc33e67d7c6" diff --git a/fixtures/has_blobs/messages.pgn b/fixtures/has_blobs/messages.pgn index fdf1205..de4acb6 100644 --- a/fixtures/has_blobs/messages.pgn +++ b/fixtures/has_blobs/messages.pgn @@ -1,29 +1,26 @@ -author USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG +author USER.59X51RSZQZR15BX86VDWG37AAMVP43PTBWD1WS66FQFCDPHAQDZ0 depth 0 kind example -lipmaa NONE prev NONE file_name:FILE.FV0FJ0YZADY7C5JTTFYPKDBHTZJ5JVVP5TCKP0605WWXYJG4VMRG -signature ZYSCKNFP8TW9DME9P9DK4Z4RV09APVEE762HK628K18NMS4DX084XKED71TCRXJNZBWY3TWDYVK1W3K496QF7Y55SCKEWP1D0SP5R30 +signature N33N7D8KFFVVPHTDE17JS7708YPAVF2F0F0AZS1FFW3D15ZH1K3HEFNQJK7KT7NMSAF8PDC1YDD5M57NPG2PTEEYPBKC1G3HFHN3J08 -author USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG +author USER.59X51RSZQZR15BX86VDWG37AAMVP43PTBWD1WS66FQFCDPHAQDZ0 depth 1 kind example -lipmaa NONE -prev TEXT.RGKRHC0APNN9FCJTVBN1NR1ZYQ9ZY34PYYASSMJ6016S30ZTWHR0 +prev TEXT.S5G187G11N2T76E2TSPS40K5QEY6S9ZC68TKEVH7JBPN27VDTKY0 file_name:FILE.YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG -signature GAZGWG8PWZSP4VSSNYD8J873CQ6KDM93SBMA9VGGC1YW66FER96HEGZQ4CJBH51YN22WMGYADNY2SCWS0JY6YPX4APFDQ60X751JJ1R +signature 53454CZKNSBK4D8NZCKWRWWE37DVANJWCS891XGRR2M8M4AJP2XNTC86MQAWAMYX3W517KWW6JD9MX3FMXNNBQ1TJS5HSK9CTW9G018 -author USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG +author USER.59X51RSZQZR15BX86VDWG37AAMVP43PTBWD1WS66FQFCDPHAQDZ0 depth 2 kind example -lipmaa NONE -prev TEXT.Z3QS1HPX756E22XWKXAXH7NTSTJGY0AHEM9KQNATTC6HHCACZGN0 +prev TEXT.5BBGSKGBHKYE6R0SJSZAGNEQA8PGJ5CMTQD1XGKKP2CHYPZR8G90 file_name:FILE.622PRNJ7C0S05XR2AHDPKWMG051B1QW5SXMN2RQHF2AND6J8VGPG -signature W94BVC4ED00Z4TJC0T3BEVC63RJYJC1J4DDS13BJTTGGXK40JSX276B9MV3GPS5JJHZW92YKAZNZ1Q4DCG0K58SCD9ZD0TVZVX7100G +signature JVN1YPVA637NF6GGPCX8GXT5FXTZPA1YM68ZWQQNXYD36CX0PSDBHXQMY7PMJYMCPFYW5BR56P2GVETM8AVYSKAFSYPVM3F7KVDW020 diff --git a/project/encoders.go b/project/encoders.go index fa9505d..867dead 100644 --- a/project/encoders.go +++ b/project/encoders.go @@ -32,7 +32,6 @@ func formatMessage(message pigeonMessage) rawMessage { str.WriteString(fmt.Sprintf("author %s\n", message.author)) str.WriteString(fmt.Sprintf("depth %d\n", message.depth)) str.WriteString(fmt.Sprintf("kind %s\n", message.kind)) - str.WriteString(fmt.Sprintf("lipmaa %s\n", message.lipmaa)) str.WriteString(fmt.Sprintf("prev %s\n\n", message.prev)) for _, item := range message.body { str.WriteString(fmt.Sprintf("%s:%s\n", item.key, item.value)) diff --git a/project/import_bundle.go b/project/import_bundle.go index 62eaf3d..6f1d157 100644 --- a/project/import_bundle.go +++ b/project/import_bundle.go @@ -7,7 +7,7 @@ import ( "path/filepath" ) -const insertMessageQuery = "INSERT INTO messages(author, depth, kind, lipmaa, prev, signature, mhash) VALUES(?1, ?2, ?3, ?4, ?5, ?6, $7)" +const insertMessageQuery = "INSERT INTO messages(author, depth, kind, prev, signature, mhash) VALUES(?1, ?2, ?3, ?4, ?5, ?6)" const insertBodyItemQuery = "INSERT INTO body_items(parent, key, value, rank) VALUES(?1, ?2, ?3, ?4)" func ingestOneMessage(msg pigeonMessage, blobIndex map[string]bool) { @@ -19,7 +19,6 @@ func ingestOneMessage(msg pigeonMessage, blobIndex map[string]bool) { msg.author, msg.depth, msg.kind, - msg.lipmaa, msg.prev, msg.signature, mhash) @@ -60,8 +59,6 @@ func ingestBlobs(p string, blobIndex map[string]bool) { if blobIndex[mhash] { addBlob(mhash, data) blobIndex[mhash] = false - } else { - fmt.Printf("Don't need %s\n", mhash) } } } diff --git a/project/import_bundle_test.go b/project/import_bundle_test.go index 2fa9a5a..080e558 100644 --- a/project/import_bundle_test.go +++ b/project/import_bundle_test.go @@ -23,9 +23,9 @@ func TestImportBundle(t *testing.T) { } messages := []string{ - "TEXT.RGKRHC0APNN9FCJTVBN1NR1ZYQ9ZY34PYYASSMJ6016S30ZTWHR0", - "TEXT.V52B1GH1XS8K1QKJG3AK127XYA23E82J0A2ZQTJ08TF8NZN2A1Y0", - "TEXT.Z3QS1HPX756E22XWKXAXH7NTSTJGY0AHEM9KQNATTC6HHCACZGN0", + "FILE.622PRNJ7C0S05XR2AHDPKWMG051B1QW5SXMN2RQHF2AND6J8VGPG", + "FILE.FV0FJ0YZADY7C5JTTFYPKDBHTZJ5JVVP5TCKP0605WWXYJG4VMRG", + "FILE.YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG", } for _, mhash := range messages { if !messageExists(mhash) { diff --git a/project/migrations.go b/project/migrations.go index 88eb640..3b2c3ef 100644 --- a/project/migrations.go +++ b/project/migrations.go @@ -34,7 +34,6 @@ var migrations = []migration{ author string NOT NULL, depth int NOT NULL, kind string NOT NULL, - lipmaa string NOT NULL, prev string NOT NULL, signature string NOT NULL, mhash string NOT NULL diff --git a/project/parser.go b/project/parser.go index f778538..54d96d8 100644 --- a/project/parser.go +++ b/project/parser.go @@ -15,7 +15,6 @@ type pigeonMessage struct { author string depth int64 kind string - lipmaa string prev string body []pigeonBodyItem signature string @@ -42,7 +41,7 @@ type parserState struct { type parserOutput struct { /** `messages` is an array of messages. The messages are SHALLOW verified. That means the message has a valid signature and syntax, - but `depth`, `lipmaa` and `prev` have not been scrutinized for validity. */ + but `depth` and `prev` have not been scrutinized for validity. */ messages []pigeonMessage /** `blobIndex` is a hash where keys represent each unique blob foud in a bundle. This is required to avoid ingesting unwanted @@ -118,9 +117,6 @@ func parseHeader(state *parserState) { case "kind": state.buffer.kind = chunks[1] return - case "lipmaa": - state.buffer.lipmaa = chunks[1] - return case "prev": state.buffer.prev = chunks[1] return diff --git a/project/verify.go b/project/verify.go index 4987fcc..60018fa 100644 --- a/project/verify.go +++ b/project/verify.go @@ -108,7 +108,6 @@ func verifyShallow(message *pigeonMessage) error { return err } buffer.Write([]byte(fmt.Sprintf("kind %s\n", message.kind))) - buffer.Write([]byte(fmt.Sprintf("lipmaa %s\n", message.lipmaa))) buffer.Write([]byte(fmt.Sprintf("prev %s\n", message.prev))) buffer.Write([]byte("\n")) for count, bodyItem := range message.body {