在會計核算的一些場景下,當用戶對總帳進行匯總時,通常會基於明細帳產生的明細資料匯總獲得總帳,其中所述總帳也稱總分類帳,是按國家規定會計科目進行分類登記的帳簿,總帳能全面、總括地反映和記錄經濟業務引起的資金運動和財務收支情況,並為編制會計報表提供資料支撐。
所述明細帳在通常的實踐中,使用的是分戶帳。所述分戶帳是明細帳的一種,是總帳各科目的詳細記錄,也是與單位對帳的依據。由於總帳包含多個科目,所以總帳節點匯總的總帳資料可能來源於多種類型的分戶帳節點。
在一種場景下,當某一類型的分戶帳節點產生明細流水時,會以非同步訊息的方式將其通知總帳節點。在訊息實際傳輸過程中,由於網路環境存在異常,導致訊息到總帳節點過程中可能出現延遲、丟失、亂序等情況,由此導致總帳匯總錯誤;在另外一種場景下,當某一類型的分戶帳資料被惡意篡改,由此導致總帳匯總錯誤,從而導致總分(總帳和多種類型分戶帳資料)核對資料不一致。
基於此,在本發明中,提出一種基於總帳記帳節點和不同類型的分戶帳記帳節點在區塊鏈上處理和同步不同類型的記帳交易請求,並將所記帳交易包括不同類型的分戶帳明細,記錄在所述區塊鏈的分散式帳本中進行儲存,以使所述總帳記帳節點基於所述分散式帳本匯總產生總帳,來避免傳統的分戶帳單點故障以及總分核對資料不一致的技術方案。
在實現時,總帳記帳節點可以不再僅是單個節點,而是由多個節點組成的總帳叢集組成。分戶帳記帳節點,可以不再僅是支援某一業務類型的單個節點,而是由多個支援該業務類型的多個設備組成的分戶帳叢集組成,該叢集內設備可以共用同一私密金鑰或者每台設備獨立維護一個私密金鑰,該私密金鑰用於記帳交易的加密。該業務類型的叢集負責接收交易發起者發起的對應該業務類型的記帳交易,其中,該記帳交易包括與該分戶帳記帳節點對應的記帳業務相關的分戶帳明細記錄;在區塊鏈網路中,存在多個支援不同業務類型的分戶帳叢集。
例如,總帳記帳節點實際是由3台設備組成的總帳叢集。支援存款業務類型的分戶帳記帳節點實際是由5台設備組成的存款分戶帳叢集;支持貸款業務類型的分戶帳記帳節點實際是由7台設備組成的貸款分戶帳叢集;支持虛擬帳業務類型的分戶帳記帳節點實際是由9台設備組成的虛擬帳分戶帳叢集。支援存款業務分戶帳記帳節點負責接收交易發起者發起的存款業務的記帳交易,該記帳交易包括至少一條存款明細記錄,比如:存款帳戶名、存入金額,帳戶餘額。
當存款業務分戶帳記帳節點,接收到上述儲存記帳交易後,將該記帳交易同步所述區塊鏈中的其它記帳節點,所述其它記帳節點具體可以是總帳記帳節點、支援其它業務類型的分戶帳記帳節點,比如:貸款分戶帳記帳節點、虛擬帳分戶帳記帳節點;在這種場景下,上述其它記帳節點,基於存款記帳節點私密金鑰對應的公開金鑰對該儲存記帳交易解密後,獲得該儲存記帳交易並對其發起共識處理,並確定該記帳交易有效性。所採用的共識演算法以及具體的共識過程,在本發明中不再進行詳述,本領域技術人員在將本發明記載的技術方案付諸實現時,可以參考相關技術中的記載。例如,對於聯盟鏈而言,可以採用諸如PBFT演算法,或者其它類似的共識演算法。
當上述其它記帳節點針對該存款記帳交易共識處理後,會向存款業務分戶帳記帳節點發送通知訊息。基於所採用的共識演算法的要求,若共識通過,該存款業務分戶帳記帳節點將所述存款記帳交易所包含存款分戶帳明細,記錄在所述區塊鏈的分散式帳本中進行儲存。當上述存款分戶帳明細儲存在區塊鏈的分散式帳本後,總帳記帳節點基於該分散式帳本進行分戶帳匯總,產生總帳。
例如:上述區塊鏈的分散式帳本中記錄有存款分戶帳明細、貸款分戶帳明細、虛擬帳分戶帳明細;總帳記帳節點匯總上述三種分戶帳明細,產生總帳。
在以上技術方案中,由於在區塊鏈中儲存的是不同業務類型的分戶帳的記帳交易,所述記帳交易包括與所述分戶帳記帳節點對應的記帳業務相關的分戶帳明細記錄;並且,在針對不同業務類型的分戶帳的記帳交易過程,引入了針對區塊鏈上儲存的上述多個不同業務類型分戶帳記帳資訊的同步記帳;因此,總帳節點與多個不同業務類型的分戶帳記帳節點共用一套分戶帳帳本,總帳節點基於本機存放區的分戶帳帳本副本,從而可以從根本上解決了總帳與多個不同業務類型的分戶帳核對時出現的速度慢、時效性差和資料不一致的問題,並且由於分戶帳帳本的多節點分散式儲存,避免了單點資料丟失或被惡意篡改。
下面通過具體實施例並結合具體的應用場景對本發明進行描述。
請參考圖1,圖1是本發明一實施例提供的一種基於區塊鏈的記帳方法,應用於分戶帳記帳節點;所述區塊鏈包括作為區塊鏈成員節點的至少一總帳記帳節點和若干分戶帳記帳節點;其中,各分戶帳記帳節點分別對應不同類型的記帳業務,所述方法執行以下步驟:
步驟102、接收交易發起者發起的記帳交易;其中,所述記帳交易包括與所述分戶帳記帳節點對應的記帳業務相關的分戶帳明細記錄;
步驟104、將所述記帳交易同步所述區塊鏈中的其它記帳節點,以發起針對所述記帳交易的共識處理;
步驟106、回應於所述記帳交易共識通過的通知訊息,將所述分戶帳明細記錄在所述區塊鏈的分散式帳本中進行儲存,以使所述總帳記帳節點基於所述區塊鏈的分散式帳本進行分戶帳匯總產生總帳。
在本發明所描述的區塊鏈,具體可以包括私有鏈、共有鏈以及聯盟鏈等,在本發明中不進行特別限定。
例如,在一個場景中,上述區塊鏈具體可以是由多個不同業務類型的分戶帳記帳節點、總帳記帳節點作為聯盟成員組成的一個聯盟鏈;該聯盟鏈的運營方可以依託於該聯盟鏈,來部署針對上述交易發起者發起的記帳交易的記帳業務;而以上所描述的作為聯盟成員的多個支持不同業務類型的分戶帳記帳節點、總帳記帳節點可以作為上述記帳業務的一個業務節點。當某一業務類型的分戶帳記帳節點對此業務類型的記帳交易在區塊鏈內發起同步,若其它記帳節點若對該記帳交易達成共識,則會向發起該記帳交易的的分戶帳記帳節點回應共識成功訊息,由該記帳交易對應的分戶帳記帳節點發起在聯盟鏈中的分散式資料庫進行儲存,完成上述記帳交易的“上鏈”記帳。
不同業務類型的分戶帳記帳節點只能接收處理該業務類型的記帳交易,若該記帳交易與該分戶帳記帳節點對應的記帳業務類型不同,則所述分戶帳記帳節點不接納處理該交易,即該記帳交易對應分戶帳記帳節點,只能對該業務類型的記帳交易有記帳許可權,對其它業務類型記帳交易,只能進行同步獲取其它業務類型記帳交易並進行共識,不能發起首次寫入分散式帳本操作,總帳記帳節點不能直接接收處理任何業務類型的記帳交易。
例如,在示出的一種實施方式中,若該交易業務類型與分戶帳記帳節點對應的記帳業務類型不同,則該分戶帳記帳節點不接納處理該交易,而在所述區塊鏈中廣播該記帳交易。若有與該交易類型相對應的分戶帳記帳節點收到,則該分戶帳記帳節點按步驟102至步驟106描述的方法進行記帳業務處理。
若區塊鏈對該記帳交易共識失敗,則該分戶帳記帳節點向該交易發起者返回記帳失敗的通知訊息。
例如,在示出的一種實施方式中,該區塊鏈為聯盟鏈,存在3f+1個記帳節點,其中f為正整數;該區塊鏈搭載使用的共識演算法是PBFT。若針對該記帳交易少於2f+1個節點對該交易達成共識,說明針對該交易共識未通過,則該分戶帳記帳節點向該交易發起者返回記帳失敗的通知訊息。
需要說明的是,在本發明中所描述的記帳交易,是指某一類型分戶帳的交易發起者通過區塊鏈的用戶端創建,並需要最終發佈至區塊鏈的分散式資料庫中的一筆資料,所述該筆資料包括:記帳業務類型、分戶帳明細記錄。
區塊鏈中的交易,通常存在狹義的交易以及廣義的交易之分。狹義的交易是指使用者向區塊鏈發佈的一筆價值轉移;例如,在傳統的比特幣區塊鏈網路中,交易可以是使用者在區塊鏈中發起的一筆轉帳。而廣義的交易是指使用者向區塊鏈發佈的一筆具有業務意圖的業務資料;例如,運營方可以基於實際的業務需求搭建一個聯盟鏈,依託於聯盟鏈部署一些與價值轉移無關的其它類型的線上業務(比如,防偽業務、租房業務、車輛調度業務、保險理賠業務、信用服務、醫療服務等),而在這類聯盟鏈中,交易可以是使用者在聯盟鏈中發佈的一筆具有業務意圖的業務訊息或者業務請求。
以下以上述區塊鏈為聯盟鏈,包括:多個業務類型的分戶帳記帳節點以及總帳記帳節點為例,對本發明的技術方案進行詳細說明;
其中,需要強調的是,以上述多個業務類型的分戶帳記帳節點以及總帳記帳節點為例僅為示例性說明。
請參見圖2,圖2為本發明示出的一種聯盟鏈的架構圖。
如圖2所示,有三種業務類型的分戶帳記帳節點以及總帳記帳節點,均可以作為聯盟成員加入到聯盟鏈,並將各自對應業務類型產生的記帳交易,以交易的形式發佈至聯盟鏈,並在該交易經過聯盟鏈中的共識節點的共識處理之後,在聯盟鏈中的分散式資料庫進行儲存,完成上述記帳交易的“上鏈”儲存。
請繼續參見圖2,在本發明中,在上述聯盟鏈上儲存的記帳交易,具體可以由該記帳交易的分戶帳明細記錄、記帳交易類型、記帳交易摘要等三部分組成。
在示出的一種實施方式中,類型1的分戶帳記帳節點接收交易發起者發起的類型1的記帳交易;其中,所述記帳交易包括:記帳交易類型為類型1、類型1分戶帳明細記錄、該筆記帳交易摘要;其中,該筆記帳交易摘要為類型1的分戶帳記帳節點基於持有的私密金鑰進行簽名獲得;類型1的分戶帳記帳節點將所述記帳交易同步所述區塊鏈中的其它記帳節點,比如:類型2、類型3的分戶帳記帳節點、總帳記帳節點,以發起針對所述記帳交易的共識處理;
如果上述其它記帳節點,對所述記帳交易共識通過,則向類型1的分戶帳記帳節點發送的共識通過通知訊息。以該區塊鏈為聯盟鏈,該區塊鏈搭載使用的共識演算法是PBFT為例,存在3f+1個記帳節點,其中f為正整數。若針對該記帳交易少於2f+1個節點對該交易達成共識,說明針對該交易共識未通過。比如:該類型1的分戶帳記帳節點,若收到達到或超過2f+1個節點共識通過通知訊息,則針對該交易共識通過。
該類型1的分戶帳記帳節點,將所述分戶帳明細記錄在所述區塊鏈的分散式帳本中進行儲存,請參見圖2所示,區塊鏈中儲存類型1的分戶帳帳本,其以使所述總帳記帳節點基於類型1的分戶帳帳本進行分戶帳匯總產生總帳。
在示出的一種實施方式中,類型2的分戶帳記帳節點接收交易發起者發起的類型2的記帳交易;其中,所述記帳交易包括:記帳交易類型為類型2、類型2分戶帳明細記錄、該筆記帳交易摘要;其中,該筆記帳交易摘要為類型2的分戶帳記帳節點基於持有的私密金鑰進行簽名獲得;類型2的分戶帳記帳節點將所述記帳交易同步所述區塊鏈中的其它記帳節點,比如:類型1、類型3的分戶帳記帳節點、總帳記帳節點,以發起針對所述記帳交易的共識處理;
以該區塊鏈為聯盟鏈,該區塊鏈搭載使用的共識演算法是PBFT為例,存在3f+1個記帳節點,其中f為正整數。若針對該記帳交易少於2f+1個節點對該交易達成共識,說明針對該交易共識未通過。比如:該類型2的分戶帳記帳節點,若未收到達到2f+1個節點共識通過通知訊息,則針對該交易共識未通過。該類型2的分戶帳記帳節點,則向該交易發起者返回記帳失敗的通知訊息。
在示出的一種實施方式中,類型3的分戶帳記帳節點接收交易發起者發起的類型2的記帳交易;其中,所述記帳交易包括:記帳交易類型為類型2、類型2分戶帳明細記錄;在將該記帳交易同步所述區塊鏈中的其它記帳節點之前,類型3的分戶帳記帳節點獲取該交易業務類型,為業務類型2,與類型3的分戶帳記帳節點對應的記帳業務類型即類型3,不相同,則類型3的分戶帳記帳節點不接納處理該交易,而在所述區塊鏈中廣播該記帳交易。假如類型2的分戶帳記帳節點收到類型3的分戶帳記帳節點廣播的該交易,則該類型2的分戶帳記帳節點按步驟102至步驟106描述的方法進行記帳業務處理。
在示出的一種實施方式中,總帳記帳節點接收交易發起者發起的類型3的記帳交易;其中,所述記帳交易包括:記帳交易類型為類型3、類型3分戶帳明細記錄;總帳記帳節點不接納處理該交易,而在所述區塊鏈中廣播該記帳交易。假如類型3的分戶帳記帳節點收到總帳記帳節點廣播的該交易,則該類型3的分戶帳記帳節點按步驟102至步驟106描述的方法進行記帳業務處理。
在示出的一種實施方式中,請參見圖2所示,區塊鏈中的分散式資料庫中儲存有:類型1的分戶帳帳本、類型2的分戶帳帳本、類型3的分戶帳帳本;總帳記帳節點基於本機存放區的類型1、類型2、類型3分戶帳帳本副本,按總帳的會計核算規則進行總帳的匯總,這裡會計核算規則不再一一詳述。
通過以上實施例可見,由於在本發明中,在區塊鏈中儲存的與某一業務類型對應相關的記帳交易,是分散式儲存於多個分戶帳記帳節點、總帳節點在區塊鏈上,不再採用單一業務類型分戶帳記帳節點中心化集中儲存,避免了業務單點故障;任何業務類型分戶帳的變化都會同步到區塊鏈的分散式資料庫中,總帳記帳節點資料可以快速獲取該分戶帳的更新。由於總帳節點與多個不同業務類型的分戶帳記帳節點共用一套分戶帳帳本,總帳節點基於本機存放區的分戶帳帳本副本,從而可以從根本上解決了總帳與多個不同業務類型的分戶帳核對時出現的速度慢、時效性差和資料不一致的問題,並且由於分戶帳帳本的多節點分散式儲存,避免了單點資料丟失或被惡意篡改。
與上述方法實施例相對應,本發明還提供了一種基於區塊鏈的記帳裝置的實施例。本發明的基於區塊鏈的記帳裝置的實施例可以應用在電子設備上。裝置實施例可以通過軟體實現,也可以通過硬體或者軟硬體結合的方式實現。以軟體實現為例,作為一個邏輯意義上的裝置,是通過其所在電子設備的處理器將非揮發性記憶體中對應的電腦程式指令讀取到記憶體中運行形成的。從硬體層面而言,如圖3所示,為本發明的基於區塊鏈的記帳裝置所在電子設備的一種硬體結構圖,除了圖3所示的處理器、記憶體、網路介面、以及非揮發性記憶體之外,實施例中裝置所在的電子設備通常根據該電子設備的實際功能,還可以包括其他硬體,對此不再贅述。
圖4是本發明一示例性實施例示出的一種基於區塊鏈的記帳裝置的方塊圖。
請參考圖4,所述基於區塊鏈的記帳裝置40可以應用在前述圖3所示的電子設備中;所述區塊鏈包括作為區塊鏈成員節點的至少一總帳記帳節點和若干分戶帳記帳節點;其中,各分戶帳記帳節點分別對應不同類型的記帳業務;所述裝置40包括有:獲取模組401、記帳模組402和返回模組403。
獲取模組401,用於分戶帳記帳節點接收交易發起者發起的記帳交易;其中,所述記帳交易包括與所述分戶帳記帳節點對應的記帳業務相關的分戶帳明細記錄;
記帳模組402,用於將所述記帳交易同步所述區塊鏈中的其它記帳節點,以發起針對所述記帳交易的共識處理;用於回應於所述記帳交易共識通過的通知訊息,將所述分戶帳明細記錄在所述區塊鏈的分散式帳本中進行儲存,以使所述總帳記帳節點基於所述區塊鏈的分散式帳本進行分戶帳匯總產生總帳。
在本實施例中,所述記帳交易包括指示所述記帳交易對應的記帳業務的類型的業務標識;所述將所述記帳交易同步所述區塊鏈中的其它記帳節點之前,所述獲取模組401進一步:
若所述業務標識與所述分戶帳記帳節點對應的記帳業務類型不同,則所述分戶帳記帳節點不接納處理該交易,而在所述區塊鏈中廣播該記帳交易。
在本實施例中,所述裝置40還包括:
返回模組403,用於若所述區塊鏈對所述記帳交易共識失敗,則向所述交易發起者返回記帳失敗的通知訊息。
在本實施例中,所述區塊鏈為聯盟鏈。
在本實施例中,所述區塊鏈搭載的共識演算法為PBFT演算法。
對於裝置實施例而言,由於其基本對應於方法實施例,所以相關之處參見方法實施例的部分說明即可。以上所描述的裝置實施例僅僅是示意性的,其中所述作為分離元件說明的模組可以是或者也可以不是實體上分開的,作為模組顯示的元件可以是或者也可以不是實體模組,即可以位於一個地方,或者也可以分佈到多個網路模組上。可以根據實際的需要選擇其中的部分或者全部模組來實現本發明方案的目的。本領域普通技術人員在不付出創造性勞動的情況下,即可以理解並實施。
上述實施例闡明的系統、裝置、模組或模組,具體可以由電腦晶片或實體實現,或者由具有某種功能的產品來實現。一種典型的實現設備為電腦,電腦的具體形式可以是個人電腦、筆記型電腦、蜂巢式電話、相機電話、智慧型電話、個人數位助理、媒體播放機、導航設備、電子郵件收發設備、遊戲控制台、平板電腦、可穿戴設備或者這些設備中的任意幾種設備的組合。
與上述方法實施例相對應,本發明還提供了一種電子設備的實施例。該電子設備包括:處理器以及用於儲存機器可執行指令的記憶體;其中,處理器和記憶體通常通過內部匯流排相互連接。在其他可能的實現方式中,所述設備還可能包括外部介面,以能夠與其他設備或者元件進行通信。
在本實施例中,通過讀取並執行所述記憶體儲存的與基於區塊鏈的記帳的控制邏輯對應的機器可執行指令,所述處理器被促使:
分戶帳記帳節點接收交易發起者發起的記帳交易;其中,所述記帳交易包括與所述分戶帳記帳節點對應的記帳業務相關的分戶帳明細記錄;所述區塊鏈包括作為區塊鏈成員節點的至少一總帳記帳節點和若干分戶帳記帳節點;其中,各分戶帳記帳節點分別對應不同類型的記帳業務;
將所述記帳交易同步所述區塊鏈中的其它記帳節點,以發起針對所述記帳交易的共識處理;
回應於所述記帳交易共識通過的通知訊息,將所述分戶帳明細記錄在所述區塊鏈的分散式帳本中進行儲存,以使所述總帳記帳節點基於所述區塊鏈的分散式帳本進行分戶帳匯總產生總帳。
在本實施例中,所述記帳交易包括指示所述記帳交易對應的記帳業務的類型的業務標識;所述將所述記帳交易同步所述區塊鏈中的其它記帳節點之前,還包括:
若所述業務標識與所述分戶帳記帳節點對應的記帳業務類型不同,則所述分戶帳記帳節點不接納處理該交易,而在所述區塊鏈中廣播該記帳交易。
在本實施例中,通過讀取並執行所述記憶體儲存的與基於區塊鏈的記帳的控制邏輯對應的機器可執行指令,所述處理器被促使:
若所述區塊鏈對所述記帳交易共識失敗,則向所述交易發起者返回記帳失敗的通知訊息。
本領域技術人員在考慮說明書及實踐這裡公開的發明後,將容易想到本發明的其它實施方案。本發明旨在涵蓋本發明的任何變型、用途或者適應性變化,這些變型、用途或者適應性變化遵循本發明的一般性原理並包括本發明未公開的本技術領域中的公知常識或慣用技術手段。說明書和實施例僅被視為示例性的,本發明的真正範圍和精神由下面的申請專利範圍指出。
應當理解的是,本發明並不局限於上面已經描述並在圖式中示出的精確結構,並且可以在不脫離其範圍進行各種修改和改變。本發明的範圍僅由所附的申請專利範圍來限制。
以上所述僅為本發明的較佳實施例而已,並不用以限制本發明,凡在本發明的精神和原則之內,所做的任何修改、等同替換、改進等,均應包含在本發明保護的範圍之內。In some scenarios of accounting, when users summarize the general ledger, they usually obtain the general ledger based on the detailed data generated by the subsidiary ledger. The general ledger is also called the general ledger, which is classified according to national regulations. Registered account books and general ledger can comprehensively and comprehensively reflect and record the capital movement and financial income and expenditure caused by economic business, and provide data support for the preparation of accounting statements.
In the usual practice, the subsidiary account uses a separate account. The sub-account is a type of subsidiary account, which is a detailed record of each subject of the general ledger and is also the basis for reconciliation with the unit. Since the general ledger contains multiple accounts, the general ledger data summarized by the general ledger node may come from multiple types of sub-ledger nodes.
In one scenario, when a certain type of sub-account node generates a detailed flow, it will be notified to the general ledger node in an asynchronous message. In the actual transmission of the message, due to the abnormal network environment, the message may be delayed, lost, or out of order in the process of the message to the general ledger node, which leads to the general ledger summary error; in another scenario, Types of sub-ledger data are maliciously tampered with, which leads to errors in the general ledger summary, resulting in inconsistent check data for the total score (general ledger and multiple types of sub-ledger data).
Based on this, in the present invention, a method based on general ledger accounting nodes and different types of sub-account accounting nodes to process and synchronize different types of accounting transaction requests on the blockchain is proposed, and the accounting transactions include different types of sub-accounts. The account details are recorded in the distributed ledger of the blockchain for storage, so that the general ledger accounting node generates a general ledger based on the decentralized ledger summary, to avoid the failure of traditional account-based billing points and The total score checks technical solutions with inconsistent data.
In implementation, the general ledger accounting node can no longer be a single node, but a general ledger cluster composed of multiple nodes. The sub-account billing node can no longer be a single node that supports a certain type of business, but is composed of a sub-account cluster composed of multiple devices that support the type of business, and the devices in the cluster can share the same private key. Key or each device independently maintains a private key, which is used for encryption of accounting transactions. The business type cluster is responsible for receiving the accounting transaction corresponding to the business type initiated by the transaction initiator, where the accounting transaction includes the sub-account detailed records related to the accounting service corresponding to the sub-accounting billing node; in the blockchain network In the road, there are multiple account clusters that support different business types.
For example, the general ledger accounting node is actually a general ledger cluster composed of 3 devices. The sub-accounting node that supports the deposit business type is actually a deposit sub-account cluster composed of 5 devices; the sub-accounting node that supports the loan business type is actually a loan sub-account cluster composed of 7 devices; supports virtual The account-separated account bookkeeping node of the account service type is actually a virtual account-separated account cluster composed of 9 devices. The sub-account bookkeeping node that supports the deposit business is responsible for receiving the bookkeeping transaction of the deposit business initiated by the transaction initiator. The bookkeeping transaction includes at least one deposit detail record, such as the name of the deposit account, the deposit amount, and the account balance.
When the individual account bookkeeping node of the deposit service receives the above-mentioned storage bookkeeping transaction, it synchronizes the bookkeeping transaction with other bookkeeping nodes in the blockchain. The other bookkeeping nodes may specifically be general ledger bookkeeping nodes and support other business types. The individual account accounting nodes, such as: loan individual account accounting nodes, virtual account individual account accounting nodes; in this scenario, the other accounting nodes mentioned above are stored based on the public key corresponding to the private key of the deposit accounting node After the accounting transaction is decrypted, the stored accounting transaction is obtained and consensus processing is initiated on it, and the validity of the accounting transaction is determined. The adopted consensus algorithm and the specific consensus process will not be described in detail in the present invention. Those skilled in the art can refer to the records in related technologies when implementing the technical solutions recorded in the present invention. For example, for alliance chains, algorithms such as PBFT or other similar consensus algorithms can be used.
After the above-mentioned other accounting nodes process the deposit accounting transaction by consensus, they will send a notification message to the separate account accounting node of the deposit business. Based on the requirements of the adopted consensus algorithm, if the consensus is passed, the deposit business sub-accounting node records the deposit accounting transaction including the deposit sub-account details in the distributed ledger of the blockchain. store. When the above-mentioned deposit account details are stored in the distributed ledger of the blockchain, the general ledger accounting node performs the aggregated account based on the distributed ledger to generate the general ledger.
For example: the above-mentioned distributed ledger of the blockchain records the details of deposit sub-accounts, loan sub-accounts, and virtual accounts sub-accounts; the general ledger accounting node summarizes the above three sub-account details to generate a general ledger.
In the above technical solution, since the accounting transactions of different business types are stored in the blockchain, the accounting transactions include the detailed records of the individual accounts related to the accounting services corresponding to the individual account accounting nodes ; And, in the accounting transaction process for the different types of business accounts, the introduction of the synchronization accounting for the above-mentioned multiple different types of business account accounting information stored on the blockchain; therefore, the general ledger node is different from multiple The split account bookkeeping nodes of the business type share a set of split account books. The general ledger node is based on the copy of the split account book in the local storage area, which can fundamentally solve the split between the general ledger and multiple different business types. The problems of slow speed, poor timeliness and inconsistent data in account check, and because of the multi-node distributed storage of the account book, it avoids the loss of single point of data or malicious tampering.
The present invention will be described below through specific embodiments in combination with specific application scenarios.
Please refer to Figure 1. Figure 1 is a block chain-based accounting method provided by an embodiment of the present invention, which is applied to a split account accounting node; the block chain includes at least one general ledger accounting as a member node of the block chain Node and a number of sub-accounting nodes; wherein each sub-accounting node corresponds to different types of accounting services, and the method executes the following steps:
Step 102: Receive a billing transaction initiated by the transaction initiator; wherein the billing transaction includes a sub-account detail record related to the billing service corresponding to the sub-account billing node;
Step 104: Synchronize the accounting transaction with other accounting nodes in the blockchain to initiate a consensus process for the accounting transaction;
Step 106: In response to the notification message that the accounting transaction consensus is passed, record the sub-account details in the distributed ledger of the blockchain for storage, so that the general ledger accounting node is based on the zone The distributed ledger of the block chain conducts sub-account aggregation to generate general ledger.
The blockchain described in the present invention may specifically include a private chain, a shared chain, and a consortium chain, etc., which are not particularly limited in the present invention.
For example, in a scenario, the above-mentioned blockchain may specifically be a consortium chain composed of multiple account bookkeeping nodes and general ledger bookkeeping nodes of different business types as alliance members; the operator of the consortium chain can rely on this The alliance chain is used to deploy the accounting services for the accounting transactions initiated by the above transaction initiators; and the multiple sub-account accounting nodes and general ledger accounting nodes that support different business types as members of the alliance described above can be used as the above accounting services A business node. When a single account bookkeeping node of a certain business type initiates synchronization of the bookkeeping transaction of this business type in the blockchain, if other bookkeeping nodes reach a consensus on the bookkeeping transaction, they will report to the branch account that initiated the bookkeeping transaction The accounting node responds to the consensus success message, and the individual account accounting node corresponding to the accounting transaction initiates storage in the distributed database in the alliance chain to complete the "chain" accounting of the above accounting transaction.
The sub-account billing nodes of different business types can only receive and process the accounting transactions of the business type. If the billing transaction is different from the billing service type corresponding to the sub-account billing node, the sub-account billing node will not accept and process the billing transaction. Transaction, that is, the accounting transaction corresponding to the sub-accounting node, can only have the accounting permission for the accounting transaction of this type of business, and for accounting transactions of other types of business, it can only be synchronized to obtain accounting transactions of other types of business and reach a consensus, and cannot be initiated. When writing to the distributed ledger operation for the first time, the general ledger accounting node cannot directly receive and process accounting transactions of any type of business.
For example, in an embodiment shown, if the transaction service type is different from the accounting service type corresponding to the individual account accounting node, the individual account accounting node does not accept to process the transaction, and in the blockchain Broadcast the accounting transaction. If a sub-account accounting node corresponding to the transaction type receives it, the sub-account accounting node performs accounting service processing according to the method described in step 102 to step 106.
If the blockchain fails in the consensus of the accounting transaction, the individual account accounting node returns a notification message of the accounting failure to the transaction initiator.
For example, in the illustrated embodiment, the blockchain is a consortium chain, and there are 3f+1 accounting nodes, where f is a positive integer; the consensus algorithm used by the blockchain is PBFT. If less than 2f+1 nodes reach a consensus on the transaction for the accounting transaction, indicating that the consensus for the transaction is not passed, the individual account accounting node returns a notification message of accounting failure to the transaction initiator.
It should be noted that the accounting transaction described in the present invention refers to the transaction initiator of a certain type of sub-account creation through the user end of the blockchain, and it needs to be finally published to the distributed database of the blockchain A piece of data, including: the type of bookkeeping business and the detailed record of the sub-account.
There are usually narrow transactions and broad transactions in transactions in the blockchain. A transaction in a narrow sense refers to a transfer of value issued by a user to the blockchain; for example, in a traditional Bitcoin blockchain network, a transaction can be a transfer initiated by the user in the blockchain. In a broad sense, a transaction refers to a piece of business data with business intent released by a user to the blockchain; for example, an operator can build a consortium chain based on actual business needs, and rely on the consortium chain to deploy some other types that are not related to value transfer. Online business (for example, anti-counterfeiting business, rental business, vehicle dispatch business, insurance claims business, credit service, medical service, etc.), and in this type of alliance chain, a transaction can be a transaction issued by the user in the alliance chain. Intent business message or business request.
The following takes the above-mentioned blockchain as the alliance chain, including: multiple business types of separate account bookkeeping nodes and general ledger bookkeeping nodes as examples, to describe the technical scheme of the present invention in detail;
Among them, it should be emphasized that the above-mentioned multiple business types of separate account bookkeeping nodes and general ledger bookkeeping nodes as examples are only illustrative.
Please refer to FIG. 2, which is an architecture diagram of a consortium chain shown in the present invention.
As shown in Figure 2, there are three types of business accounts and general ledger accounting nodes, all of which can join the alliance chain as alliance members, and publish the accounting transactions generated by their respective business types to the alliance in the form of transactions After the transaction is processed by the consensus nodes in the alliance chain, it is stored in the distributed database in the alliance chain to complete the "on-chain" storage of the above-mentioned accounting transactions.
Please continue to refer to FIG. 2. In the present invention, the accounting transaction stored on the above-mentioned alliance chain can be specifically composed of three parts: the sub-account detail record of the accounting transaction, the accounting transaction type, and the accounting transaction summary.
In the illustrated embodiment, the type 1 sub-accounting node receives the type 1 accounting transaction initiated by the transaction initiator; wherein the accounting transaction includes: the type of the accounting transaction is type 1, type 1 sub-accounting details Record, the summary of the note-taking transaction; where the note-taking transaction summary is the type 1 sub-accounting node signed based on the private key held; the type 1 sub-accounting node synchronizes the accounting transaction Other accounting nodes in the blockchain, such as type 2 and type 3 separate account accounting nodes, general ledger accounting nodes, to initiate consensus processing for the accounting transaction;
If the above-mentioned other accounting nodes pass a consensus on the accounting transaction, the consensus pass notification message is sent to the type 1 account-sharing accounting node. Taking the blockchain as a consortium chain, and the consensus algorithm used by the blockchain is PBFT as an example, there are 3f+1 accounting nodes, where f is a positive integer. If less than 2f+1 nodes reach a consensus on the transaction for the accounting transaction, it means that the consensus on the transaction has not been passed. For example, if the account-sharing node of this type 1 receives a notification message that the consensus of 2f+1 nodes is reached or exceeded, the consensus is passed for the transaction.
This type 1 split account bookkeeping node records the split account details in the distributed ledger of the blockchain for storage. Please refer to Figure 2 for storage of type 1 split accounts in the blockchain A ledger, which enables the general ledger accounting node to perform sub-ledger aggregation based on the type 1 sub-ledger account book to generate a general ledger.
In the illustrated embodiment, the type 2 separate account bookkeeping node receives the type 2 bookkeeping transaction initiated by the transaction initiator; wherein, the bookkeeping transaction includes: the type of accounting transaction is type 2 and type 2 separate account details Record, the summary of the note-taking transaction; where the summary of the note-taking transaction is the type 2 sub-accounting node signed based on the private key held; the type 2 sub-accounting node synchronizes the accounting transaction Other accounting nodes in the block chain, such as type 1, type 3 individual account accounting nodes, general ledger accounting nodes, to initiate consensus processing for the accounting transaction;
Taking the blockchain as a consortium chain, and the consensus algorithm used by the blockchain is PBFT as an example, there are 3f+1 accounting nodes, where f is a positive integer. If less than 2f+1 nodes reach a consensus on the transaction for the accounting transaction, it means that the consensus on the transaction has not been passed. For example, if the type 2 account-sharing node does not receive the notification message that the consensus of 2f+1 nodes is reached, the consensus for the transaction is not passed. The type 2 sub-account billing node returns a notification message of billing failure to the transaction initiator.
In the illustrated embodiment, the type 3 separate account accounting node receives the type 2 accounting transaction initiated by the transaction initiator; wherein, the accounting transaction includes: the accounting transaction type is type 2 and type 2 separate account details Record; before synchronizing the accounting transaction with other accounting nodes in the blockchain, the type 3 individual account accounting node obtains the transaction business type, which is business type 2, which corresponds to the type 3 individual account accounting node The type of billing service is type 3, and if they are not the same, the split account billing node of type 3 does not accept to process the transaction, and broadcasts the billing transaction in the blockchain. If the type 2 sub-accounting node receives the transaction broadcast by the type 3 sub-accounting node, the type 2 sub-accounting node performs accounting service processing according to the method described in step 102 to step 106.
In the illustrated embodiment, the general ledger billing node receives the type 3 billing transaction initiated by the transaction initiator; wherein, the billing transaction includes: the billing transaction type is type 3, type 3 sub-account details record; general ledger The billing node does not accept to process the transaction, but broadcasts the billing transaction in the blockchain. If the type 3 sub-accounting node receives the transaction broadcasted by the general ledger accounting node, the type 3 sub-accounting node performs accounting service processing according to the method described in step 102 to step 106.
In an embodiment shown, please refer to Figure 2. The distributed database in the blockchain stores: type 1 household account book, type 2 household account book, type 3 Household ledger account book; The general ledger accounting node is based on the type 1, type 2, type 3 split account book copy of the local storage area, and summarizes the general ledger according to the accounting rules of the general ledger. The accounting rules are no longer here. Detailed one by one.
It can be seen from the above embodiments that, in the present invention, the accounting transactions corresponding to a certain business type stored in the blockchain are stored in a distributed manner in multiple account accounting nodes, and the general ledger node is stored in the blockchain. On the above, the centralized storage of single business type account bookkeeping nodes is no longer used, which avoids a single point of business failure; any business type account changes will be synchronized to the distributed database of the blockchain, the general ledger account node The information can quickly obtain the update of the sub-account. Since the general ledger node shares a set of sub-account book with multiple different business types of sub-account bookkeeping nodes, the general ledger node is based on the copy of the sub-account book in the local storage area, which can fundamentally solve the general ledger The problems of slow speed, poor timeliness, and inconsistent data when checking with multiple different types of business accounts, and due to the multi-node distributed storage of the accounts, avoiding single point data loss or malicious tampering.
Corresponding to the foregoing method embodiment, the present invention also provides an embodiment of a blockchain-based accounting device. The embodiment of the blockchain-based accounting device of the present invention can be applied to electronic equipment. The device embodiments can be implemented by software, or can be implemented by hardware or a combination of software and hardware. Take software implementation as an example. As a logical device, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory through the processor of the electronic device where it is located. From a hardware perspective, as shown in Figure 3, it is a hardware structure diagram of the electronic equipment where the blockchain-based accounting device of the present invention is located, except for the processor, memory, network interface, and network interface shown in Figure 3. In addition to the non-volatile memory, the electronic device in which the device is located in the embodiment usually includes other hardware according to the actual function of the electronic device, which will not be repeated here.
Fig. 4 is a block diagram showing a block chain-based accounting device according to an exemplary embodiment of the present invention.
Please refer to FIG. 4, the block chain-based accounting device 40 can be applied to the electronic device shown in FIG. 3; the block chain includes at least one general ledger accounting node and a number of points as member nodes of the block chain. Account bookkeeping node; among them, each account bookkeeping node corresponds to different types of accounting services; the device 40 includes: an acquisition module 401, an accounting module 402, and a return module 403.
The obtaining module 401 is used for the sub-account billing node to receive the billing transaction initiated by the transaction initiator; wherein the billing transaction includes the sub-account detail record related to the billing business corresponding to the sub-account billing node;
The accounting module 402 is used for synchronizing the accounting transaction with other accounting nodes in the blockchain to initiate a consensus process for the accounting transaction; used to respond to the notification message that the accounting transaction consensus is passed, and The sub-account detailed records are stored in the distributed ledger of the blockchain, so that the general ledger accounting node performs sub-account aggregation based on the distributed ledger of the blockchain to generate a general ledger.
In this embodiment, the accounting transaction includes a service identifier indicating the type of accounting service corresponding to the accounting transaction; before the accounting transaction is synchronized with other accounting nodes in the blockchain, the acquisition module Group 401 further:
If the service identifier is different from the accounting service type corresponding to the individual account accounting node, the individual account accounting node does not accept to process the transaction, but broadcasts the accounting transaction in the blockchain.
In this embodiment, the device 40 further includes:
The return module 403 is configured to, if the blockchain fails to agree on the accounting transaction, return a notification message of accounting failure to the transaction initiator.
In this embodiment, the blockchain is a consortium chain.
In this embodiment, the consensus algorithm carried by the blockchain is the PBFT algorithm.
For the device embodiment, since it basically corresponds to the method embodiment, the relevant part can refer to the part of the description of the method embodiment. The above-described device embodiments are merely illustrative. The modules described as separate elements may or may not be physically separate, and the elements displayed as modules may or may not be physical modules. It can be located in one place, or it can be distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solution of the present invention. Those of ordinary skill in the art can understand and implement it without creative work.
The system, device, module, or module set forth in the foregoing embodiments may be specifically implemented by a computer chip or entity, or implemented by a product with a certain function. A typical implementation device is a computer. The specific form of the computer can be a personal computer, a notebook computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email receiving and sending device, and a game control A desktop, a tablet, a wearable device, or a combination of any of these devices.
Corresponding to the foregoing method embodiment, the present invention also provides an embodiment of an electronic device. The electronic device includes a processor and a memory for storing machine executable instructions; wherein the processor and the memory are usually connected to each other through an internal bus. In other possible implementation manners, the device may also include an external interface to be able to communicate with other devices or components.
In this embodiment, by reading and executing the machine executable instructions stored in the memory and corresponding to the control logic of blockchain-based accounting, the processor is prompted to:
The sub-account billing node receives the billing transaction initiated by the transaction initiator; wherein, the billing transaction includes sub-account detail records related to the billing business corresponding to the sub-account billing node; the blockchain includes the block chain as a block At least one general ledger accounting node and several sub-account accounting nodes of the chain member nodes; wherein, each sub-account accounting node corresponds to different types of accounting services;
Synchronizing the accounting transaction with other accounting nodes in the blockchain to initiate a consensus process for the accounting transaction;
In response to the notification message that the accounting transaction consensus is passed, the sub-account details are recorded in the distributed ledger of the blockchain for storage, so that the general ledger accounting node is based on the blockchain’s Distributed ledger is used to generate general ledger by sub-account summary.
In this embodiment, the accounting transaction includes a service identifier indicating the type of accounting service corresponding to the accounting transaction; before synchronizing the accounting transaction with other accounting nodes in the blockchain, it further includes:
If the service identifier is different from the accounting service type corresponding to the individual account accounting node, the individual account accounting node does not accept to process the transaction, but broadcasts the accounting transaction in the blockchain.
In this embodiment, by reading and executing the machine executable instructions stored in the memory and corresponding to the control logic of blockchain-based accounting, the processor is prompted to:
If the blockchain fails to agree on the accounting transaction, it returns a notification message of accounting failure to the transaction initiator.
Those skilled in the art will easily think of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses, or adaptive changes of the present invention. These variations, uses, or adaptive changes follow the general principles of the present invention and include common knowledge or conventional technical means in the technical field not disclosed by the present invention. . The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present invention are pointed out by the following patent application scope.
It should be understood that the present invention is not limited to the precise structure described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the scope of the attached patent application.
The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the present invention. Within the scope of protection.