diff --git a/blockchain/abci.go b/blockchain/abci.go index 006cae3..d385501 100644 --- a/blockchain/abci.go +++ b/blockchain/abci.go @@ -45,7 +45,6 @@ func requireIDPrefix(id, pref string) error { return nil } - func verifyAndExtractBody(db *badger.DB, tx []byte) (map[string]interface{}, error) { var outer struct { Body types.CommiterTxBody `json:"body"` @@ -131,13 +130,13 @@ func (app *PromiseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { if strings.TrimSpace(p.Text) == "" { return abci.ResponseCheckTx{Code: 2, Log: "promise.text is required"} } - if p.Due == 0 { - return abci.ResponseCheckTx{Code: 2, Log: "promise.due is required"} - } + //if p.Due == 0 { + // return abci.ResponseCheckTx{Code: 2, Log: "promise.due is required"} + //} // Commitment due - if c.Due == 0 { - return abci.ResponseCheckTx{Code: 2, Log: "commitment.due is required"} - } + //if c.Due == 0 { + // return abci.ResponseCheckTx{Code: 2, Log: "commitment.due is required"} + //} // Связность по ER if c.PromiseID != p.ID { @@ -165,7 +164,7 @@ func (app *PromiseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { return abci.ResponseCheckTx{Code: 3, Log: err.Error()} } - // Существование коммитера (у тебя уже было — оставляю) + // Существование коммитера if err := app.db.View(func(txn *badger.Txn) error { _, e := txn.Get([]byte(c.CommiterID)) if e == badger.ErrKeyNotFound { @@ -229,7 +228,7 @@ func (app *PromiseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { var single struct { Body types.BeneficiaryTxBody `json:"body"` - Signature string `json:"signature"` + Signature string `json:"signature"` } if err2 := json.Unmarshal(req.Tx, &single); err2 == nil && single.Body.Type == "beneficiary" { if err := requireIDPrefix(single.Body.ID, "beneficiary"); err != nil { @@ -310,7 +309,7 @@ func (app *PromiseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliver { var outer struct { Body types.BeneficiaryTxBody `json:"body"` - Signature string `json:"signature"` + Signature string `json:"signature"` } if err := json.Unmarshal(req.Tx, &outer); err == nil && outer.Body.Type == "beneficiary" { // (пока без проверки подписи — можно добавить политику позже) diff --git a/docs/database_schema.md b/docs/database_schema.md index 2d405d9..00ba10c 100644 --- a/docs/database_schema.md +++ b/docs/database_schema.md @@ -3,41 +3,41 @@ ![[ER.svg]]
-@startuml + @startuml -entity Promise { - * ID: uuid - -- - * text: text - * due: datetime - BeneficiaryID: uuid - ParentPromiseID: uuid -} + entity Promise { + * ID: uuid + -- + * text: string + due: datetime + BeneficiaryID: uuid + ParentPromiseID: uuid + } -entity Beneficiary { - * ID: uuid - -- - * name: string -} + entity Beneficiary { + * ID: uuid + -- + * name: string + } -entity Commitment { - * ID: uuid - -- - PromiseID: int - CommiterID: int - due: datetime -} + entity Commitment { + * ID: uuid + -- + PromiseID: uuid + CommiterID: uuid + due: datetime + } -entity Commiter { - * ID: int - -- - * name: string -} + entity Commiter { + * ID: uuid + -- + * name: string + } -Commitment }|--|| Promise : belongs to -Commitment }|--|| Commiter : made by -Promise }o--|| Beneficiary : has -Promise }--o Promise : parent of + Commitment }|--|| Promise : belongs to + Commitment }|--|| Commiter : made by + Promise }o--|| Beneficiary : has + Promise }--o Promise : parent of -@enduml -
\ No newline at end of file + @enduml +