suspending most annoying DUE checks
maybe, not forever...
This commit is contained in:
parent
cdbef17af3
commit
388db03fc0
2 changed files with 47 additions and 48 deletions
|
|
@ -45,7 +45,6 @@ func requireIDPrefix(id, pref string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func verifyAndExtractBody(db *badger.DB, tx []byte) (map[string]interface{}, error) {
|
func verifyAndExtractBody(db *badger.DB, tx []byte) (map[string]interface{}, error) {
|
||||||
var outer struct {
|
var outer struct {
|
||||||
Body types.CommiterTxBody `json:"body"`
|
Body types.CommiterTxBody `json:"body"`
|
||||||
|
|
@ -131,13 +130,13 @@ func (app *PromiseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
|
||||||
if strings.TrimSpace(p.Text) == "" {
|
if strings.TrimSpace(p.Text) == "" {
|
||||||
return abci.ResponseCheckTx{Code: 2, Log: "promise.text is required"}
|
return abci.ResponseCheckTx{Code: 2, Log: "promise.text is required"}
|
||||||
}
|
}
|
||||||
if p.Due == 0 {
|
//if p.Due == 0 {
|
||||||
return abci.ResponseCheckTx{Code: 2, Log: "promise.due is required"}
|
// return abci.ResponseCheckTx{Code: 2, Log: "promise.due is required"}
|
||||||
}
|
//}
|
||||||
// Commitment due
|
// Commitment due
|
||||||
if c.Due == 0 {
|
//if c.Due == 0 {
|
||||||
return abci.ResponseCheckTx{Code: 2, Log: "commitment.due is required"}
|
// return abci.ResponseCheckTx{Code: 2, Log: "commitment.due is required"}
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Связность по ER
|
// Связность по ER
|
||||||
if c.PromiseID != p.ID {
|
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()}
|
return abci.ResponseCheckTx{Code: 3, Log: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Существование коммитера (у тебя уже было — оставляю)
|
// Существование коммитера
|
||||||
if err := app.db.View(func(txn *badger.Txn) error {
|
if err := app.db.View(func(txn *badger.Txn) error {
|
||||||
_, e := txn.Get([]byte(c.CommiterID))
|
_, e := txn.Get([]byte(c.CommiterID))
|
||||||
if e == badger.ErrKeyNotFound {
|
if e == badger.ErrKeyNotFound {
|
||||||
|
|
@ -229,7 +228,7 @@ func (app *PromiseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
|
||||||
|
|
||||||
var single struct {
|
var single struct {
|
||||||
Body types.BeneficiaryTxBody `json:"body"`
|
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 err2 := json.Unmarshal(req.Tx, &single); err2 == nil && single.Body.Type == "beneficiary" {
|
||||||
if err := requireIDPrefix(single.Body.ID, "beneficiary"); err != nil {
|
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 {
|
var outer struct {
|
||||||
Body types.BeneficiaryTxBody `json:"body"`
|
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" {
|
if err := json.Unmarshal(req.Tx, &outer); err == nil && outer.Body.Type == "beneficiary" {
|
||||||
// (пока без проверки подписи — можно добавить политику позже)
|
// (пока без проверки подписи — можно добавить политику позже)
|
||||||
|
|
|
||||||
|
|
@ -3,41 +3,41 @@
|
||||||
![[ER.svg]]
|
![[ER.svg]]
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@startuml
|
@startuml
|
||||||
|
|
||||||
entity Promise {
|
entity Promise {
|
||||||
* ID: uuid
|
* ID: uuid
|
||||||
--
|
--
|
||||||
* text: text
|
* text: string
|
||||||
* due: datetime
|
due: datetime
|
||||||
BeneficiaryID: uuid
|
BeneficiaryID: uuid
|
||||||
ParentPromiseID: uuid
|
ParentPromiseID: uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Beneficiary {
|
entity Beneficiary {
|
||||||
* ID: uuid
|
* ID: uuid
|
||||||
--
|
--
|
||||||
* name: string
|
* name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Commitment {
|
entity Commitment {
|
||||||
* ID: uuid
|
* ID: uuid
|
||||||
--
|
--
|
||||||
PromiseID: int
|
PromiseID: uuid
|
||||||
CommiterID: int
|
CommiterID: uuid
|
||||||
due: datetime
|
due: datetime
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Commiter {
|
entity Commiter {
|
||||||
* ID: int
|
* ID: uuid
|
||||||
--
|
--
|
||||||
* name: string
|
* name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
Commitment }|--|| Promise : belongs to
|
Commitment }|--|| Promise : belongs to
|
||||||
Commitment }|--|| Commiter : made by
|
Commitment }|--|| Commiter : made by
|
||||||
Promise }o--|| Beneficiary : has
|
Promise }o--|| Beneficiary : has
|
||||||
Promise }--o Promise : parent of
|
Promise }--o Promise : parent of
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
</details>
|
</details>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue